Skip to content

Instantly share code, notes, and snippets.

View rjmacarthy's full-sized avatar
🎮
The Tetris effect

rjmacarthy rjmacarthy

🎮
The Tetris effect
View GitHub Profile
@rjmacarthy
rjmacarthy / build.sh
Created March 6, 2018 16:26
Start angular4 app with Jenkins and expose port
#!/bin/bash
pm2 stop angular4
. ~/.nvm/nvm.sh
nvm use 9.7.1
npm install
pm2 start start.sh --name angular4
@rjmacarthy
rjmacarthy / EscrowContract.sol
Last active December 3, 2017 05:36
Escrow Contract Solidity
pragma solidity ^0.4.4;
import './Ownable.sol';
contract EscrowContract is Ownable {
address public owner;
address public recipientAddress;
address public parent;
uint public escrowAmount;
EscrowStatuses public status = EscrowStatuses.Pending;
enum EscrowStatuses { Paid, Pending, Complete, Cancelled, Partial }
@rjmacarthy
rjmacarthy / HelloWorld.sol
Created July 13, 2017 13:02
Hello World Ethereum Smart Contract
pragma solidity ^0.4.4;
contract HelloWorld {
address public owner;
string public message;
function HelloWorld() {
owner = msg.sender;
message = 'Hello, world';
}
@rjmacarthy
rjmacarthy / backup.sh
Created July 12, 2017 16:27
Mongo backup
#!/bin/bash
#Force file syncronization and lock writes
mongo -u "username" -p "password" --authenticationDatabase "admin" --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="127.0.0.1" #replace with your server ip
MONGO_PORT="27017"
MONGO_DATABASE="dbname" #replace with your database name
@rjmacarthy
rjmacarthy / bitcore-dirived-private-public.js
Created January 11, 2017 16:43
BIP38 Derived Public/Private key Bitcore.js
var bitcore = require('bitcore');
var assert = require('assert');
var index = 1;
// Create a new HD private key.
var hdPrivateKey = new bitcore.HDPrivateKey(); //returns xpriv...
//Use private key to create drived public key.
var hdPublicKey = hdPrivateKey.hdPublicKey;
// Derive address from public key
@rjmacarthy
rjmacarthy / interval.js
Created October 10, 2016 15:50
Interval without setTimeout
import { random, delay } from 'lodash';
export const interval = (fn) => {
fn();
delay(() => { interval(fn); }, randomNumber());
};
var randomNumber = () => {
return random(1000, 10000)
};
@rjmacarthy
rjmacarthy / binary-gap.js
Last active December 5, 2018 11:46
Binary Gap JavaScript
var tests = [234534534234];
tests.forEach(function (t) {
Test(t);
});
function Test(N) {
var bin = N.toString(2);
var b = 0;
var col = bin.split("1").filter(function (val) {
upstream app_www {
server 127.0.0.1:3000;
}
# the nginx server instance
server {
listen 80;
server_name www.www;
return 301 http://www.www.www;
@rjmacarthy
rjmacarthy / draggable-polygon
Created September 1, 2016 14:14
Draggable polygon fiddle
https://jsfiddle.net/3L140cg3/16/
@rjmacarthy
rjmacarthy / mysql
Last active August 11, 2016 10:53
docker mysql
FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO %i
# Install
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:tag
# Go to bash
docker exec -it some-mysql bash
# mysql