Skip to content

Instantly share code, notes, and snippets.

@cflems
cflems / linestyle.js
Created October 24, 2017 18:33
Comb for lines that create difficulty reading code.
const readline = require('readline');
const colors = require('colors');
const rl = readline.createInterface({
input: process.stdin,
});
let line = 1, warn = 0;
rl.on('line', (ln) => {
if (ln.length > 80) console.warn(('#'+(++warn)+' ').red.bold
@cflems
cflems / hook.php
Created August 17, 2017 04:33
PHP Github Webhook Template
<?php
function sh ($cmd, $cwd) {
$descriptorspec = array(
1 => array('pipe', 'w'), // stdout is a pipe that the child will write to
2 => array('pipe', 'w') // stderr
);
$resource = proc_open($cmd, $descriptorspec, $pipes, $cwd);
if (is_resource($resource)) {
$output = stream_get_contents($pipes[2]);
$output .= PHP_EOL;
@cflems
cflems / aggressive_scrape.js
Created August 11, 2017 18:59
Obtain a local copy of any static website. Background images and some references may not work properly.
const http = require('http');
const https = require('https');
const fs = require('fs');
const path = require('path');
const url = require('url');
const exec = require('child_process').execSync;
const jq = require('jquery');
const jsdom = require('jsdom');
const SAVE_DIR = path.dirname(__filename)+'/scrape';
@cflems
cflems / hook.js
Last active August 16, 2017 17:13
// npm install githubhook
const githubhook = require('githubhook');
const exec = require('child_process').exec;
let config = {
ip: '0.0.0.0',
port: 1234,
url: '/push',
secret: 'whatever',
branch: 'master',