Category Archives: Uncategorized

getting started contributing to jekyll admin (front end) & feature “specify folder to upload static files to”

Screenshot from 2017-04-25 04-32-28

THIS POST IS A WORK IN PROGRESS.
I was able to get static file upload to a different directory. directory is automatically created by jekyll admin. Thumbnail even populates in http://localhost:3000/admin/staticfiles !

First steps for addressing: https://github.com/jekyll/jekyll-admin/issues/201
Feature request: Specify folder to upload static files to #201

Next steps: make a little GUI button for toggling “assets” or something like that (not sure how to make it not an arbitrary folder, but still allow user input into it)

https://github.com/jekyll/jekyll-admin/blob/3463b7ed98d43e721389ade9470c06dd863a5b9e/src/actions/staticfiles.js

const foo = "static/" + staticfileAPIUrl(file.name);

return fetch(foo, {
          method: 'PUT',
          body: payload
        })


 

 

==================================== INSTALL ======================

my distribution had ruby installed already.

sudo apt install ruby-dev

git clone https://github.com/jekyll/jekyll-admin && cd jekyll-admin

sudo gem update –system

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing rainbow (2.2.2), and Bundler cannot continue.

sudo gem install rake

https://github.com/jekyll/jekyll-admin/issues/201

Bundle complete! 9 Gemfile dependencies, 46 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
script/bootstrap: line 7: npm: command not found

sudo apt install npm

nrw@chai:~/projects/jekyll-admin$ script/server-frontend

sh: 1: npm-run-all: not found

npm install npm-run-all

nrw@chai:~/projects/jekyll-admin$ script/server-frontend

/usr/bin/env: ‘node’: No such file or directory

sudo apt install nodejs –> already installed’

 

https://github.com/jekyll/jekyll-admin/search?utf8=%E2%9C%93&q=upload&type=

 

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

 

sh: 1: babel-node: not found

nrw@chai:~/projects/jekyll-admin$ npm-run-all clean lint build:*
npm-run-all: command not found

 

https://askubuntu.com/questions/603921/cant-use-npm-installed-packages-from-command-linen

https://github.com/jekyll/jekyll-admin/issues/201https://www.npmjs.com/package/npm-run-all

https://www.npmjs.com/package/babel-node

nrw@chai:~/projects/jekyll-admin$ npm install babel-node

> babel-node@6.5.3 postinstall /home/nrw/projects/jekyll-admin/node_modules/babel-node
> node message.js; sleep 10; exit 1;

┌─────────────────────────────────────────────────────────────────────────────┐
| Hello there undefined 😛 │
| You tried to install babel-node. This is not babel-node 🚫 │
| You should npm install -g babel-cli instead 💁 . │
| I took this module to prevent somebody from pushing malicious code. 🕵 │
| Be careful out there, undefined! 👍 │
└─────────────────────────────────────────────────────────────────────────────┘
^C

npm install babel-cli

 

npm ERR! Failed at the jekyll-admin@0.4.1 start-message script ‘babel-node tools/startMessage.js’.

npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jekyll-admin package,
npm ERR! not with npm itself.

nodejs –version

npm –version

https://www.npmjs.com/package/babel-cli

npm update npm -g

 

nrw@chai:~/projects/jekyll-admin$ script/server-frontend
> jekyll-admin@0.4.1 remove-dist /home/nrw/projects/jekyll-admin
> rimraf ./lib/jekyll-admin/public

/home/nrw/projects/jekyll-admin/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
throw e;
^

Error: Couldn’t find preset “stage-0” relative to directory “/home/nrw/projects/jekyll-admin”

 

nrw@chai:~/projects/jekyll-admin$ npm install babel-preset-stage-0
/home/nrw/projects/jekyll-admin/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
throw e;
^

Error: Couldn’t find preset “react” relative to directory “/home/nrw/projects/jekyll-admin”
/home/nrw/projects/jekyll-admin/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
throw e;
^

Error: Couldn’t find preset “react” relative to directory “/home/nrw/projects/jekyll-admin”

 

npm install react

 

$ script/boostrap

script/server-frontend

==================================== static file URL ======================

https://github.com/jekyll/jekyll-admin/search?p=2&q=upload&type=&utf8=%E2%9C%93

 

https://github.com/jekyll/jekyll-admin/blob/3463b7ed98d43e721389ade9470c06dd863a5b9e/src/actions/staticfiles.js

 

https://github.com/jekyll/jekyll-admin/search?utf8=%E2%9C%93&q=staticfileAPIUrl&type=

// send the put request

return fetch(staticfileAPIUrl(file.name), { method: ‘PUT’, body: payload })

 

https://github.com/jekyll/jekyll-admin/blob/2e31c09a265868d5f29b8bce407041da70a7261b/src/utils/fetch.js

https://github.com/jekyll/jekyll-admin/blob/3463b7ed98d43e721389ade9470c06dd863a5b9e/src/constants/api.js

 

http://stackoverflow.com/questions/377768/string-concatenation-in-ruby#377787

 

https://github.com/jekyll/jekyll-admin/blob/3463b7ed98d43e721389ade9470c06dd863a5b9e/src/constants/api.js

vi staticfiles.js

Fixing vi paragraph motion: change empty line definition to include blank lines with spaces and tabs


Vim Paragraph Motions

(code from udacity “AI for robotics” class, lesson 8 particle filters)

I was feeling frustrated as the command I use all the time, moving forward or backward by a paragraph using `{` or `}`, was skipping a complete screen up and down. In the above screenshotted example, I was moving from the start of the class definition (up an entire screen) to the end,  instead of the behavior I expected of moving from function to function within the class.

Turns out that the vim’s paragraph definition only includes completely empty lines, and does not include lines that appear empty but have whitespace such as spaces or indents.

Solution

I installed vundle and installed the vim-paragraph-motion plugin. That is, in vim.rc, I added the following bundle line below the plugin vundle.vim line.

“`
Plugin ‘VundleVim/Vundle.vim’
Bundle ‘dbakker/vim-paragraph-motion’
“`

Then I closed and reopened vim, and ran `:BundleInstall`.

Reopened the file I was editing, and voila, paragraph motion commands behaved as I was expecting.

Credit to this post.

Debugging: show whitespace including spaces and tabs

I was confused debugging this for a while, as `:set list` doesn’t show spaces and tabs! So the end character was appearing as a magically “indented” end-of-line character. My search terms were all out of whack.

“`
$
def some func():
$
“`

vs, with help from this post, using `:set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<`

“`
$
def some func():
~~~~$
“`

Bonus! vim: go to definition of variable under cursor

Also, today I discovered the use of `gd` , which moves you to where the variable under your cursor is defined!

Then you can use `Ctrl-O` to move back to where you started (and `Ctrl-I` if you want to go forward in your jump list).

Credit to this post.

Okay! Politics, in 15 minutes a day (6 easy steps)

Update: https://5calls.org has the script I’m using, already written for each issue!

Update: But uh, thesixtyfive.org scripts do have a more reasonable distinction between senators, house of representatives, republicans, and democrats…

Apparently calling is the way to go, much more effective than emails / social media. Thus I spent 10 minutes adding people as contacts to my phone (one-time).

From then on, each day it’s only a 10 minute exercise to call people.

Then I set an alarm for 10 am Monday through Friday. That’s my time to call.

Easy six steps:

  1. I used http://govtrack.us/ and looked up my 2 senators and 1 house representative (1 minute)
  2. I added my three state reps to my phone as starred contacts (3 minutes)
  3. I added four national reps to my phone as starred contacts (3 minutes)
    • Representative Paul Ryan – (202) 225-3031
    • Senator Mitch McConnell – (202) 224-2541
    • Senator Chuck Schumer – (202) 224-6542
    • Representative Nancy Pelosi – (202) 225-4965
  4. Pick a script at https://5calls.org
  5. Added that I called to my google calendar, so I can celebrate becoming involved in politics some day!

Note: You should only call representative in your state!

Note: For people in blue states, my friend says, “It matters slightly less to call, but it’s always important to let reps know what you care about so they know where to focus their energy.”

Note: Make sure you’re not using the script for Senators on your Representative. Also not the script for Democratic Senators on your Republican Senators. Sigh. (I messed this up for the Supreme Court nominee).

List of useful sites:

==========

Previously before I found 5calls.org:

 

  • I looked at the weekly script at thesixtyfive.org/weeklyCTA and pulled out the important sentence. Then followed a shorter script (2 minutes)
  • Called these 7 people during business hours and said:
    “I am opposed to the executive order signed Friday barring citizens of seven predominantly Muslim countries from entering the U.S. I encourage <Representative/Senator> to please oppose implementation of any such ban. Thanks for your hard work answering the phones!” (7 minutes)

 

===========

Above based on notes from a former Congressional Staffer:

1. Give your name, city, and zip code, and say “I don’t need a response.” That way, they can quickly confirm you are a constituent, and that they can tally you down without taking the time to input you into a response database.

2. PLEASE ONLY CALL YOUR OWN REPRESENTATIVES! Your tally will not be marked down unless you can rattle off a city and zip from the state, or are calling from an in-state area code. I know you really want to give other reps a piece of your mind, but your call will be ignored unless you can provide a zip from their district. And don’t try to make this up; I could often tell who was lying very quickly thanks to the knowledge of the state’s geography. Exceptions to this are things like Paul Ryan’s ACA poll which are national.

3. State the issue, state your position. “I am opposed to ________.” “I am in favor of _______.” “I am opposed to banning the import of phalanges.” I am in favor of a trade deal to lower the price of juice smoothies.” That’s it. That’s all we write down so we can get a tally of who is in favor, who is against. It doesn’t matter WHY you hold that opinion. The more people calling, the less detail they have time to write down. Help them out by being simple and direct. This keeps calls shorter, allowing more callers through.

4. Please be nice! The people answering the phones on Capitol Hill already had the hardest job in DC and some of the lowest pay as well, and for a month now their jobs have become absolute murder, with nonstop calls for 9 hours every day. Thank them for their hard work answering the phones, because without them our Senators could not represent us!

What does this sound like?

“Hi, my name is Mark, I’m a constituent from Seattle, zip code 98***, I don’t need a response. I am opposed to banning the sale of blueberries and I encourage the Senator to please oppose implementation of any such ban. Thanks for your hard work answering the phones!”

This is how I wish every caller had phrased their message. It makes it easier for the people answering the phones and takes less time and emotion than a long script. I know that you want to say why, but keeping it short and sweet helps the office answer more calls per hour, meaning more people get heard. The bigger the tally, the more powerful your voice.

Also, when you’re reading off the same script as 100 other callers that day… well…they know what you’re about to say, so you don’t need to use the whole script for your opinion to be heard!

Pick one issue each day, use this format (I am in favor of _____ or I oppose ______), and call your 2 Senators and 1 Representative on their DC and State Office lines, and you’ll be on your way to being heard.