Skip to content

Instantly share code, notes, and snippets.

View danielo515's full-sized avatar
🏠
Working from home

Daniel Rodríguez Rivero danielo515

🏠
Working from home
View GitHub Profile
@danielo515
danielo515 / data.json
Created October 1, 2015 12:08
Require basic example taht fails
[
{
"name":"My Cool Operator Template Created",
"text":"Created filter $FilterID$ for operator $OPName$"
}
]
@danielo515
danielo515 / fieldmangleer_extended.js
Last active October 4, 2015 14:25
An extension of the TW5 fieldmangler widget
/*\
title: $:/plugins/danielo515/OctoWiki/Widgets/FieldMangler
type: application/javascript
module-type: widget
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
@danielo515
danielo515 / colors.py
Last active December 2, 2015 13:19 — forked from jossef/colors.py
python coloring for linux, based on this answer http://stackoverflow.com/a/26445590/3191896
def color(text, *user_styles):
styles = {
# styles
'reset': '\033[0m',
'bold': '\033[01m',
'disabled': '\033[02m',
'underline': '\033[04m',
'reverse': '\033[07m',
@danielo515
danielo515 / getBGImgURLsFromCSSs.js
Last active May 3, 2016 15:49 — forked from donut/getBGImgURLsFromCSSs.js
Builds a list of images found in the linked style sheets
window.npup = (function (doc) {
var sheets = doc.styleSheets;
var hash = {}, sheet, rules, rule, url, match;
// loop the stylesheets
for (var sheetIdx=0, sheetsLen=sheets.length; sheetIdx<sheetsLen; ++sheetIdx) {
sheet = sheets[sheetIdx];
// ie or w3c stylee rules property?
rules = sheet.rules ? sheet.rules : sheet.cssRules;
// loop the rules
for (var ruleIdx=0, rulesLen=rules.length; ruleIdx<rulesLen; ++ruleIdx) {
@danielo515
danielo515 / javascript.json
Created August 11, 2016 17:10
My javascript snippets for VSCode
{
/*
// Place your snippets for JavaScript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
@danielo515
danielo515 / 100-sdflash.rules
Last active August 12, 2016 13:34
Flash an image on sd insertion
# place this at /etc/udev/rules.d/100-sdflash.rules
ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usb", NAME="MyCard" RUN+="/bin/dd bs=1M if=/path/to/image of=/dev/MyCard && echo Flash is complete!"
@danielo515
danielo515 / CrytoJS_GUUID_test.js
Last active December 14, 2016 16:25
A small benchmark to check if Crypto JS is able to generate GUUID
const CryptoJS = require("crypto-js");
const _ = require('lodash');
let i = 5000;
const keys = [];
console.time('Generating keys');
while(--i)
keys.push(CryptoJS.lib.WordArray.random(128 / 8).toString(CryptoJS.sha256));
i = 5000
while(--i)
keys.push(CryptoJS.lib.WordArray.random(128 / 8).toString(CryptoJS.sha256));

Installation

1)

brew install nginx
sudo cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist /Library/LaunchAgents

2)

Replace /usr/local/etc/nginx/nginx.conf with the nginx.conf in this gist. I'm using port 5000 for my current project. Obviously, change server_name as well, and probably the name of its access log.

@danielo515
danielo515 / axios-set-base-path.js
Last active April 29, 2017 12:59 — forked from srph/set-base-path.js
axios: Configure the base path with interceptors
var axios = require('axios');
var join = require('url-join');
// https://github.com/sindresorhus/is-absolute-url/blob/master/index.js#L7
var isAbsoluteURLRegex = /^(?:\w+:)\/\//;
axios.interceptors.request.use(function(config) {
// Concatenate base path if not an absolute URL
if ( !isAbsoluteURLRegex.test(config.url) ) {
config.url = join('http://my-api.com', config.url);