Skip to content

Instantly share code, notes, and snippets.

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

Cory Robinson crobinson42

🏠
Working from home
  • American Software
  • Northwest USA
View GitHub Profile
/*
This will create a file and trigger a download for the user.
*/
var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob(['This is the text in the file..'], {type: 'text/html'}));
a.download = 'filename_test.html';
// Append anchor to body.
document.body.appendChild(a)
@crobinson42
crobinson42 / dillon_task_filter_input.js
Created March 31, 2017 18:05
Live filter input for Dillon task board
// tamper script to add a live filter input next to search
const $table = $('table.task-list')
const $tableBody = $table.find('tbody')
const $filterInput = $('<input type="search" placeholder="filter"/>')
const filterInput = inputText => {
if (!inputText || inputText.length < 3) {
$tableBody.find('tr.hidden').map((i, el) => {
$(el).removeClass('hidden')
})
return
@wafe
wafe / gist:2000145
Created March 8, 2012 10:16
node.js uncaughtException logging using winston
var winston = require('winston'); // https://github.com/flatiron/winston
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename : 'winston.log', timestamp: true, /*maxsize: 2000, maxFiles: 5*/ })
]
});
process.on('uncaughtException', function (err) {
@guilouro
guilouro / bitbucket-pipelines.yml
Created May 15, 2017 16:55
publish npm with bitbucket pipeline
image: node:7
pipelines:
default:
- step:
script:
- printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
- npm publish
@WickyNilliams
WickyNilliams / bad.js
Last active January 30, 2020 17:46
fast builds with grunt and browserify
module.exports = function(grunt) {
"use strict";
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
paths : {
src : "<%= pkg.main %>",
@PascalAnimateur
PascalAnimateur / Place.js
Last active February 22, 2021 20:19
Geospatial example in Sails.js using native MongoDB query
/* Place model */
module.exports = {
attributes: {
name: {
type: 'string',
required: true
},
@juanpasolano
juanpasolano / api models Locations.js
Created September 9, 2014 21:50
seed database on sails js
/**
* Locations.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
seedData:[
@joepie91
joepie91 / delay-promise.js
Last active July 29, 2022 20:02
ES6 Promise.delay
module.exports = function(duration) {
return function(){
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve();
}, duration)
});
};
};
@sidola
sidola / pubsub.ts
Last active January 24, 2023 05:13
Basic typesafe pub-sub implementation in Typescript
/* ------------------------------------------
Alternative impl. as a class can be found here: https://gist.github.com/sidola/eaf987d8c4c7e8445b61dc07c33a842f
Has a way smaller footprint and less typescript magic to grasp.
------------------------------------------ */
/**
* Defines the function type of the publish function.
*
@sothmann
sothmann / logdecorator.ts
Created August 4, 2015 12:14
TypeScript Decorator - Log method calls
function log(target, key, descriptor: PropertyDescriptor) {
var originalMethod = descriptor.value;
descriptor.value = function(...args: any[]) {
let functionName = key;
console.log(functionName + "(" + args.join(", ") + ")");
let result = originalMethod.apply(this, args);
console.log("=> " + result);
return result;
};