Skip to content

Instantly share code, notes, and snippets.

View natchiketa's full-sized avatar

Sara Lara natchiketa

View GitHub Profile
@natchiketa
natchiketa / brainfarts-bash.sh
Last active November 4, 2015 16:45
Brain farts (or, things I do seldom enough that I always have to look them up)
# _EMPTY_STRING_
# The -n operator checks whether the string is not null. Effectively, this will
# return true for every case except where the string contains no characters. ie:
VAR="hello"
if [ -n "$VAR" ]; then
echo "VAR is not empty"
fi
# Similarly, the -z operator checks whether the string is null. ie:
VAR=""
if [ -z "$VAR" ]; then
@natchiketa
natchiketa / keypress-usage.md
Created October 2, 2015 20:25
Using the Node keypress package

After installing keypress (npm install keypress), running this in the Node REPL will show you what the names an codes are for different keypresses.

var keypress = require('keypress');

// make `process.stdin` begin emitting "keypress" events
keypress(process.stdin);

// listen for the "keypress" event
process.stdin.on('keypress', function (ch, key) {
@natchiketa
natchiketa / edge_length_addon.py
Last active September 16, 2015 02:26 — forked from zeffii/edge_length_addon.py
preliminary_edge_length addon
bl_info = {
"name": "Edge sum",
"author": "zeffii",
"version": (0, 1, 0),
"blender": (2, 6, 1),
"location": "3d view, N panel",
"description": "Adds edge sum box to Mesh Display.",
"wiki_url": "",
"tracker_url": "",
"category": "3D View"}
@natchiketa
natchiketa / a Super-simple Nginx reverse proxy with Homebrew on OS X.md
Last active May 18, 2023 04:54
Super-simple Nginx reverse proxy with Homebrew on OS X

Installation

1)

brew install nginx
sudo cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist /Library/LaunchAgents

2)

Replace /usr/local/etc/nginx/nginx.conf with the nginx.conf in this gist. I'm using port 5000 for my current project. Obviously, change server_name as well, and probably the name of its access log.

@natchiketa
natchiketa / pbjade.md
Last active August 29, 2015 14:24
pbjade: convert HTML in clipboard to Jade

Install the package

# You might have to sudo 
npm install -g html2jade

Make sure it's working

Try out the html2jade command. For example, with some HTML in your clipboard, do this in the shell:

@natchiketa
natchiketa / Gemfile
Last active August 29, 2015 14:24
Development and production Gemfile groups
group :development, :test do
gem 'dotenv-rails', :require => 'dotenv/rails-now'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
@natchiketa
natchiketa / min_frog_jumps.js
Created June 23, 2015 20:00
Minimum number of frog jumps
function toInt(value) {
return ~~value;
}
function minFrogJumps(X, Y, D) {
var a = Y / D;
var b = X / D;
return toInt(Math.ceil(a -b));
}
@natchiketa
natchiketa / TapeEquilibrium.js
Created June 23, 2015 19:39
Tape equilibrium solution in JavaScript
function tapeEquilibrium(A) {
var p, idx;
var leftSum = 0, rightSum = 0;
var totalSum = 0;
var lastMin, currentMin;
var N = A.length;
if (N == 2) { return Math.abs(A[0] - A[1]); }
if (N == 1) { return Math.abs(A[0]); }
@natchiketa
natchiketa / fizzbuzz.rb
Created October 2, 2014 04:41
FizzBuzz with Ruby
puts (1..100).map { |n|
w = [
('Fizz' if n % 3 == 0),
('Buzz' if n % 5 == 0)
]
.uniq()
.compact()
.join('')
w.empty? ? n : w
@natchiketa
natchiketa / alfred2_workflows.md
Last active August 29, 2015 14:06
Creating Alfred 2 Workflows

Search Results

The caniuse workflow

Say you look up 'transform':

To build this type of result:

caniuse result item