Skip to content

Instantly share code, notes, and snippets.

Avatar

WarrenCA warrenca

View GitHub Profile
View testing-bash.sh
#!/bin/bash
THE_DATE=$(date)
echo $THE_DATE
View redis-string-or-hash-insert.py
#! /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 Jul 5, 2020 — forked from dustismo/gist:6203329
How to install leveldb on ubuntu
View gist:2b29b3f688fe9d784364dd277b392a5d
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 Dec 10, 2018
Laravel Repository Pattern
View CompanyUserController.php
<?php
namespace App\Http\Controllers;
use Warrenca\Laravel\Repositories\UserRepository;
/**
* Class CompanyUserController
*/
View 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 \
View callback-hell.js
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
Async/Await ES7
View async-await.js
async function process() {
let name="john";
if (name==="john") {
return Promise.resolve("My name is john");
} else {
return Promise.reject("I am not john");
}
}
View 1-restify-server-cheatsheet.js
// 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 Dec 22, 2016 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon
View ultimate-ut-cheat-sheet.md

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 Aug 3, 2016 — forked from remmelt/bamboo-to-slack.py
Post an Atlassian Bamboo build result to Slack
View bamboo-to-slack.py
#!/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}"
You can’t perform that action at this time.