Skip to content

Instantly share code, notes, and snippets.

Avatar
🎮
The Tetris effect

Richard Macarthy rjmacarthy

🎮
The Tetris effect
View GitHub Profile
@rjmacarthy
rjmacarthy / linux-hdd-space.sh
Created Jul 16, 2018
Check hdd space liunx
View linux-hdd-space.sh
sudo du -xh / | grep -P "G\t"
df -Bg
View mong-start.sho
mongod --fork --dbpath /home/mongodata/mongodb --smallfiles --logpath /var/log/mongodb.log --logappend
@rjmacarthy
rjmacarthy / build.sh
Created Mar 6, 2018
Start angular4 app with Jenkins and expose port
View build.sh
#!/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 Dec 3, 2017
Escrow Contract Solidity
View EscrowContract.sol
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 Jul 13, 2017
Hello World Ethereum Smart Contract
View HelloWorld.sol
pragma solidity ^0.4.4;
contract HelloWorld {
address public owner;
string public message;
function HelloWorld() {
owner = msg.sender;
message = 'Hello, world';
}
View backup.sh
#!/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 Jan 11, 2017
BIP38 Derived Public/Private key Bitcore.js
View bitcore-dirived-private-public.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 Oct 10, 2016
Interval without setTimeout
View interval.js
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 Dec 5, 2018
Binary Gap JavaScript
View binary-gap.js
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) {
View nginx-config
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;