Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
🕹️

Steven de Salas sdesalas

🕹️
View GitHub Profile
@guzmonne
guzmonne / EventEmmiter.js
Created June 24, 2017 21:55
cognito-auth.EventEmitter.js
(function(win){
var events = {};
function on(event, listener) {
if (typeof events[event] !== 'object') {
events[event] = [];
}
events[event].push(listener);
}
@xarg
xarg / websql2json
Created March 3, 2015 16:27
WebSQL to jSON dump
//change table variables below according to your case and you should get a nice JSON at the end
var db = "db";
var table = "your_table";
var db = openDatabase(db, '1.0.0', '', 2 * 1024 * 1024);
db.transaction(function (tx) {
var l = [];
tx.executeSql('select * from ' + table, null, function(tx, res){
for (var i = 0; i < res.rows.length; i++) {
l.push(res.rows.item(i));
}
@misakuo
misakuo / Identicon.java
Created November 28, 2016 08:19
Generate Identicon by android
package demo.taobao.com.playground.identicon;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
@lgg
lgg / Make WordPress to use protocol relative urls
Created June 7, 2016 03:29
Make WordPress to use protocol relative urls
//make other links relative
add_filter ('site_url', 'wp_make_theme_links_protocols_relative');
add_filter ('get_option_siteurl', 'wp_make_theme_links_protocols_relative');
add_filter ('stylesheet_directory_uri', 'wp_make_theme_links_protocols_relative');
add_filter ('template_directory_uri', 'wp_make_theme_links_protocols_relative');
add_filter ('wp_get_attachment_url', 'wp_make_theme_links_protocols_relative');
add_filter ('wp_get_attachment_thumb_url', 'wp_make_theme_links_protocols_relative');
add_filter ('the_permalink', 'wp_make_theme_links_protocols_relative');
function wp_make_theme_links_protocols_relative( $link ){
$link = str_replace("http://", "//", $link);
@ryan0x44
ryan0x44 / Terraform-Blue-Green-AWS.md
Created November 19, 2015 21:57
Blue-Green AWS Auto Scaling Deployments with Terraform

A quick note on how I'm currently handling Blue/Green or A/B deployments with Terraform and AWS EC2 Auto Scaling.

In my particular use case, I want to be able to inspect an AMI deployment manually before disabling the previous deployment.

Hopefully someone finds this useful, and if you have and feedback please leave a comment or email me.

Overview

I build my AMI's using Packer and Ansible.

@alexroan
alexroan / Chainlink-PriceConsumer.sol
Last active March 23, 2022 22:18
Chainlink-PriceConsumer.sol
@19h
19h / reset.js
Created February 19, 2013 22:51
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}
/*
* RPC: https://rpc.tomochain.com mainnet, https://rpc.testnet.tomochain.com testnet
* chainId: 88 mainnet, 89 testnet
*/
const Web3 = require('web3')
const rpc = 'https://rpc.testnet.tomochain.com'
const chainId = 89
const pkey = 'YOUR_PKEY' // token holder pkey
@guifromrio
guifromrio / teamcity-agent-ubuntu.md
Last active October 21, 2022 12:35
Instructions to Setup Teamcity Agent on EC2 Ubuntu 12.04.2 Linux with NodeJS and PhantomJS
@sdesalas
sdesalas / various.sh
Created May 22, 2022 17:35
Db backup scripts
for DB in $(mysql -u root -p<password> -h <IP of DB> -e 'show databases' -s --skip-column-names); do
mysqldump -u root -p<password> -h<IP of DB> $DB > "$DB.sql";