Skip to content

Instantly share code, notes, and snippets.

@select
select / Default (Linux).sublime-keymap
Created February 6, 2015 08:19
Sublime Text replace selected text with a snippet, trigger this with a keyboard shortcut (e.g. for wrapping natural laguage strings with a call to a translation function)
// add this to your "Key Bindings - User" to trigger the snipped
{
"keys": ["ctrl+1"],
"command": "insert_snippet",
"args": {
"name": "Packages/User/php-translation-wrap-string.sublime-snippet"
},
}
@select
select / tumblr_oauth.py
Last active December 9, 2015 19:17
Tumblr OAuth for web2py
from gluon.contrib.login_methods.oauth10a_account import OAuthAccount
import pytumblr
class TumblrOAuth(OAuthAccount):
"""OAuth for Tumblr"""
# Define oauth application id and secret.
consumer_key = 'XXX'
consumer_secret = 'XXX'
@select
select / social-link-generator.html
Created February 5, 2016 22:49
Social Link Generator adopted from https://simplesharingbuttons.com
ul {
list-style: none;
position: relative;
padding: 0;
margin: 0;
box-sizing: border-box;
}
ul li {
position: relative;
@select
select / box.js
Last active November 9, 2016 15:46
Express Mongo REST API in ES6 with co and generators mongoose and lodash
'use strict';
let router = require('express').Router();
const co = require('co');
const mongoose = require('mongoose');
const Box = mongoose.model('Box');
const _ = require('lodash');
// ---
router.route('/')
@select
select / cyan-light.tmuxtheme
Last active December 17, 2017 21:03
Tmux theme: cynan white background
# Powerline Cyan Light - Tmux Theme
# github @select
# based on
# Powerline Cyan - Tmux Theme
# Created by Jim Myhrberg <contact@jimeh.me>.
#
# Inspired by vim-powerline: https://github.com/Lokaltog/powerline
#
# Requires terminal to be using a powerline compatible font, find one here:
# https://github.com/Lokaltog/powerline-fonts
@select
select / objectsToCsv.js
Last active December 19, 2022 18:17
Convert an Array of non uniform Objects to a CSV string with JavaScript
function getKeys(obj, prefix = '') {
if (typeof obj === 'undefined' || obj === null) return [];
return [
...Object.keys(obj).map(key => `${prefix}${key}`),
...Object.entries(obj).reduce((acc, [key, value]) => {
if (typeof value === 'object') return [...acc, ...getKeys(value, `${prefix}${key}.`)];
return acc;
}, []),
];
}