Skip to content

Instantly share code, notes, and snippets.

View nicholasrq's full-sized avatar
🏃‍♂️
Building an empire

Nick Skriabin nicholasrq

🏃‍♂️
Building an empire
View GitHub Profile
@nicholasrq
nicholasrq / lambda-deployment-script.js
Last active January 25, 2021 21:48
Lamda Directory structure
const { exec, execSync } = require('child_process');
const FS = require('fs');
const Path = require('path');
const execCommand = (command) => new Promise((resolve, reject) => {
exec(command, (err, stdout) => {
if (err) return reject(err);
console.log(stdout);
const childProcess = require('child_process')
const https = require('https')
const URL = require('url')
const out = (message = '') => {
console.log(message.trim().split('\n').map(r => r.trim()).join('\n'))
}
const exec = (cmd, callback) => {
if (cmd instanceof Function) {
@nicholasrq
nicholasrq / middleware.js
Created April 3, 2018 15:13
JS Middleware class in 8 lines
class Middleware{
constructor(){ this.m = [] }
use(fn){ this.m.push(fn) }
run(d, f){ this._execute(d, f) }
_execute(d, f){ this.m.reduceRight((n, c) => v => c(v, n), f)(d) }
}
// usage
const m = new Middleware();
@nicholasrq
nicholasrq / README.md
Last active March 16, 2016 13:13
Tool to control your LTSearch instances

INSTALLATION

Automatic

Run command:

curl https://gist.githubusercontent.com/nicholasrq/f2da0281e102144af3c3/raw/install | sh
@nicholasrq
nicholasrq / url_matcher.coffee
Created May 9, 2015 00:34
Tiny url-pattern matcher
###
Example:
Pattern: http{s}://example.com
Will match:
http://example.com
https://example.com
Pattern: http{s}://example.com/*
Will match:
@nicholasrq
nicholasrq / mysql_load.sh
Last active August 29, 2015 14:06
simple wrapper over the mysqldump command
#!/bin/sh
# you also can pass an argument which
# will be the name of a table in remote DB
# mysql_load users
mysql_load(){
if ! type "pv" > /dev/null
then
echo "You should install Pipe View first"
@nicholasrq
nicholasrq / sunspot_reindex.rb
Created September 17, 2014 04:40
Method to reindex sunspot model with progress bar. You just need to add it to any of your models.
def self.reindex!
model_name = self.name.to_s
total = self.count
indexed = 0.to_f
progress = 0.to_f
row_length = 100.to_f
log_level = Sunspot::Rails::LogSubscriber.logger.level
time_start = Time.now
each_second = Time.now
per_second = 0
###
"Stalkable" objects can be watched for any and all changes
@author Bryan Elliott <belliott@rsicms.com>
###
###
Detect whether an Object is using this Mixin
###
Ember.Mixin::detectInstance = (object) ->