Skip to content

Instantly share code, notes, and snippets.

@passcod
passcod / us
Created February 22, 2016 10:53
default partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {
name[Group1]= "English (US)";
key <TLDE> { [ grave, asciitilde ] };
key <AE01> { [ 1, exclam ] };
key <AE02> { [ 2, at ] };
key <AE03> { [ 3, numbersign ] };
key <AE04> { [ 4, dollar ] };
@passcod
passcod / SO_34017416.rb
Created December 1, 2015 10:11
Stylistic suggestion for StackOverflow question 34017416
File.write("/etc/nginx/sites-available/#{domain}", "
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
@passcod
passcod / 0_reuse_code.js
Created October 1, 2015 22:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

ES6

The current version of JavaScript. We support "old" browsers, so we can't use it on the client side*, but we can totally use it server-side or in other environments where we have stricter control over the JS runtime.

ES6 has various new features:

'use strict'

Put it at the top of files to switch on "strict mode" which fixes various behaviours that have led developers over the ages to call JS "broken". For example, some comparisons, especially with NaN, undefined, and null; also disables the performance-hurting with keyword.

import Twitter from 'twitter';
const client = new Twitter({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
});
let getFaves = function () {
@passcod
passcod / coc
Last active August 29, 2015 14:23
#!/usr/bin/bash
file="CODE_OF_CONDUCT.md"
gitroot="$(git rev-parse --show-toplevel)"
if [[ -z "$gitroot" ]]; then
exit
fi
cd "$gitroot"
url="http://contributor-covenant.org/version/1/1/0/code_of_conduct.md"
rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
binary: rustc
commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e
commit-date: 2015-05-13
build-date: 2015-05-14
host: x86_64-unknown-linux-gnu
release: 1.0.0
1 A
1 A4
1 A5
1 A6
1 Aa
1 AA
1 ac3_bsi_offset
1 AC3header
1 accept
1 action_function
1 bom
1 E
1 G
1 llZn7Ic
1 MI_
1 OU
1 q_dHJi04
1 stdout
2 base_url
2 cable_actions
                                                                     
                [