Skip to content

Instantly share code, notes, and snippets.

View cb1kenobi's full-sized avatar

Chris Barber cb1kenobi

View GitHub Profile
@cb1kenobi
cb1kenobi / gist:3989139
Created October 31, 2012 19:02
How to install the Titanium CLI
[sudo] npm install -g titanium
titanium sdk install --branch 3_0_X --default
@cb1kenobi
cb1kenobi / github_widescreen
Last active November 6, 2019 05:07
Greasemonkey script to make GitHub widescreen friendly. There's probably some quirks. Use at your own risk.
// ==UserScript==
// @name GitHub Widescreen
// @namespace https://github.com
// @include https://github.com/*
// @grant none
// ==/UserScript==
(function() {
var style = document.createElement("style");
style.type = "text/css";
style.innerHTML = "\
@cb1kenobi
cb1kenobi / colors.reg
Created July 22, 2014 19:37
This is my custom sane color scheme for the Windows Command Prompt that makes colors easier to see
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe]
"QuickEdit"=dword:00000001
"ScreenBufferSize"=dword:270f0082
"WindowSize"=dword:002e0082
"FontSize"=dword:000e0007
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"FaceName"="Consolas"
@cb1kenobi
cb1kenobi / appid.js
Created August 4, 2014 17:23
Titanium CLI hook that changes the app id
/* Put this file in <product dir>/plugins/appid/hooks/
* then add this to your tiapp.xml:
* <plugins>
* <plugin>appid</plugin>
* </plugins>
*/
exports.cliVersion = '>=3.2.1';
exports.init = function (logger, config, cli, appc) {
@cb1kenobi
cb1kenobi / gist:97253db17e46f814be86
Created October 20, 2014 21:07
Coda 2 vs Coda 2.5 indentation
Say you are editing an HTML file.
In Coda 2, if you type "<style>" and ENTER, the cursor lines up with the "<". If you type "foo {" and hit ENTER, the cursor lines up with "f".
In Coda 2.5, if you type "<style>" and ENTER, the cursor is tabbed in 1 level from the "<". Generally this is what you want. If you type "foo {" and hit ENTER, the cursor again is tabbed in 1 level from the "foo". The biggest annoyance is if I type "}", it doesn't automatically outdent.
@cb1kenobi
cb1kenobi / get-spam-blocklist
Last active August 29, 2015 14:10
Postfix CIDR blocklist update script
#!/usr/bin/env node
var http = require('http');
http.get({
hostname: 'www.spamhaus.org',
port: 80,
path: '/drop/drop.lasso'
}, function (res) {
if (res.statusCode !== 200) {
console.error('Failed to download http://www.spamhaus.org/drop/drop.lasso');
process.exit(1);
@cb1kenobi
cb1kenobi / update-spam-blocklist
Created May 30, 2015 00:52
Postfix CIDR blocklist update and spamassassin learn script
#!/bin/bash
curl https://www.spamhaus.org/drop/drop.lasso 2>/dev/null | sed '/^\s*;/d' | sed 's/;.*/REJECT/' > /etc/postfix/client.cidr
postfix reload
sa-learn -D --sync --spam /data/mail/cb1inc.com/chris/.Spam/{cur,new}
@cb1kenobi
cb1kenobi / fetch.js
Created October 9, 2015 03:04
Fetches all packages from NPM, caches it, then builds a list of packages containing C++ addons
var async = require('async'),
fs = require('fs'),
request = require('request'),
pkgs,
addons = [];
async.series([
function (next) {
if (fs.existsSync('./packages.json')) {
pkgs = require('./packages.json');
@cb1kenobi
cb1kenobi / examples.js
Created February 22, 2016 04:49
ES2015/6 Examples
const koa = require('koa');
const app = koa();
// logger
app.use(async (ctx, next) => {
const start = new Date;
await next();
const ms = new Date - start;
console.log('%s %s - %s', this.method, this.url, ms);
});
@cb1kenobi
cb1kenobi / longestWord.js
Created March 28, 2016 05:07
Longest word
function longestWord(s) {
return s.split(/\b/).filter(chunk => chunk.trim()).reduce((a, b) => a.length > b.length ? a : b);
}
console.log(longestWord('I am so awesome it hurts')); // awesome