Skip to content

Instantly share code, notes, and snippets.

@hilkeheremans
hilkeheremans / .drone.yml
Created April 28, 2016 11:13
Drone CI with nodejs, npm and private modules
# drone.yml for node js CI with npm login
# Don't forget to configure DRONE_SERVER and DRONE_SERVER
# Now create a secrets.yml (OUTSIDE of your repo!!) (see other file)
# then run drone secure --repo <drone_repo_name> --in <path>/secrets.yml
build:
unit_tests:
image: risingstack/alpine:3.3-v4.2.6-1.1.3
commands:
- npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
- npm install
@rauchg
rauchg / README.md
Last active April 13, 2025 04:29
require-from-twitter
@chrisfrancis27
chrisfrancis27 / example.js
Created January 25, 2016 11:51
Bookshelf hash IDs
'use strict';
const _ = require('lodash');
const bookshelf = require('../config/bookshelf');
const hasher = require('../utils/hasher');
require('./thing');
let Example = Bookshelf.model.extend({
tableName: 'examples',
@joepie91
joepie91 / vpn.md
Last active April 19, 2025 00:38
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@allaniftrue
allaniftrue / easylist_adservers.php
Created October 18, 2015 10:29
Extract Easylist Adservers from the huge file for DNS
<?php
# Get contents from easylist domain
$content = file_get_contents('easylist.txt');
# Extract adserver list only
preg_match('/(\!\s\*\*\*\seasylist:easylist\/easylist_adservers\.txt\s\*\*\*)[^"]+(\!\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-Third\-party\sadverts\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\!)/', $content, $extracted, PREG_OFFSET_CAPTURE);
/*
* Remove unnecessary strings from every URL
@glortho
glortho / prop_nullable.js
Last active April 24, 2018 11:12
Nullable PropType for React
/**
* Usage:
*
* import React from 'react';
* import nullable from 'prop_nullable';
*
* let myClass = React.createClass({
* propTypes: {
* myProp: nullable( React.PropTypes.string ).isRequired,
* myOtherProp: nullable( [React.PropTypes.string, React.PropTypes.number] )
@kristopolous
kristopolous / hn_seach.js
Last active July 24, 2023 04:12
hn job query search
// Usage:
// Copy and paste all of this into a debug console window of the "Who is Hiring?" comment thread
// then use as follows:
//
// query(term | [term, term, ...], term | [term, term, ...], ...)
//
// When arguments are in an array then that means an "or" and when they are seperate that means "and"
//
// Term is of the format:
// ((-)text/RegExp) ( '-' means negation )
@selaromi
selaromi / rails-postgres-wercker-database_url.md
Last active June 26, 2017 08:27
wercker.yml for Rails with Postgresql and DATABASE_URL (docker stack)

RAILS & POSTGRES WITH WERCKER AND DATABASE_URL

Basically, if you prefer to use DATABASE_URL in your application better than creating the whole database.yml thing, set the following ENV variable in your wercker app settings:

  • APP_POSTGRES_PASSWORD (required)
  • APP_POSTGRES_USER (optional)
  • APP_POSTGRES_DB (optional)
  • DATABASE_URL (value below)

name: DATABASE_URL

@justmoon
justmoon / custom-error.js
Last active November 19, 2024 02:40 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@wrburgess
wrburgess / import_and_parse_remote_csv_rails.md
Created November 3, 2014 14:24
Import and parse remote csv with Rails
require 'csv'
require 'open-uri'

csv_text = open('http://www.vvv.hh.yyy.ggg/~hhhh/uuuu.csv')
csv = CSV.parse(csv_text, :headers=>true)
csv.each do |row|
  puts row
end