Skip to content

Instantly share code, notes, and snippets.

@warrenca
warrenca / testing-bash.sh
Created August 13, 2020 02:02
testing-bash
#!/bin/bash
THE_DATE=$(date)
echo $THE_DATE
#! /usr/bin/env python
import redis
import random
import sys
r = redis.Redis(host = 'localhost', port = 6379)
REDIS_SETGET = False
REDIS_HSET = False
@warrenca
warrenca / gist:2b29b3f688fe9d784364dd277b392a5d
Created July 5, 2020 06:33 — forked from dustismo/gist:6203329
How to install leveldb on ubuntu
sudo apt-get install libsnappy-dev
wget https://leveldb.googlecode.com/files/leveldb-1.9.0.tar.gz
tar -xzf leveldb-1.9.0.tar.gz
cd leveldb-1.9.0
make
sudo mv libleveldb.* /usr/local/lib
cd include
sudo cp -R leveldb /usr/local/include
@warrenca
warrenca / CompanyUserController.php
Created December 10, 2018 00:28
Laravel Repository Pattern
<?php
namespace App\Http\Controllers;
use Warrenca\Laravel\Repositories\UserRepository;
/**
* Class CompanyUserController
*/
@warrenca
warrenca / docker-etcd.sh
Created May 25, 2017 01:58
docker-etcd.sh
#!/bin/bash
docker stop etcd; docker rm etcd; docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd /usr/local/bin/etcd \
-name etcd0 \
-advertise-client-urls http://${HostIP}:2379,http://${HostIP}:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://${HostIP}:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://${HostIP}:2380 \
@warrenca
warrenca / callback-hell.js
Created March 3, 2017 10:33
Callback hell
function process(callback) {
var name = "john";
if (name==="john") {
callback(null, "My name is john");
} else {
callback("I am not john");
}
}
process(function(error, message) {
@warrenca
warrenca / async-await.js
Last active May 17, 2017 23:25
Async/Await ES7
async function process() {
let name="john";
if (name==="john") {
return Promise.resolve("My name is john");
} else {
return Promise.reject("I am not john");
}
}
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@warrenca
warrenca / ultimate-ut-cheat-sheet.md
Created December 22, 2016 03:12 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@warrenca
warrenca / bamboo-to-slack.py
Created August 3, 2016 14:20 — forked from remmelt/bamboo-to-slack.py
Post an Atlassian Bamboo build result to Slack
#!/usr/bin/python
"""
Create a stage in your project, make it the last stage.
Make a task in the stage with this inline script:
#! /bin/bash
/some/path/bamboo-to-slack.py "${bamboo.planKey}" "${bamboo.buildPlanName}" "${bamboo.buildResultsUrl}"