Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
ROOT=~/.nmlnk
NODE_MODULES_REPOSITORY="$ROOT/repository"
# check package-lock.json file is present
if [ ! -f "package-lock.json" ]; then
echo "File package-lock.json not found!"
exit 1
fi
@cybrown
cybrown / bignumber.js.d.ts
Created January 9, 2016 15:18
Starting web3 TypeScript type definition
declare module "bignumber.js" {
class BigNumber {
constructor(value: number|string); // Acccepts a number OR a string
toNumber(): number;
// Those static attributes could have been in the module, a few lines beneath
static ROUND_DOWN: any;
static config(arg: any): void;
}
@cybrown
cybrown / Gruntfile.js
Created April 12, 2014 12:37
Gruntfile to reboot nodejs when a file is modified.
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-nodemon');
grunt.initConfig({
nodemon: {
dev: {
options: {
file: 'index.js',
watchedExtensions: ['js'],
watchedFolders: ['src']
@cybrown
cybrown / sublime3.reg
Created January 2, 2014 20:53
Add open in sublime text entry in folders menu in windows
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text]
[HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text\command]
@="C:\\Program Files\\Sublime Text 3\\sublime_text.exe \"%1\""
@cybrown
cybrown / web.xml
Created December 3, 2013 16:26
Simple web.xml file for JEE Application Servlet 3.0
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0">
</web-app>
@cybrown
cybrown / persistence.xml
Created December 3, 2013 16:25
persistence.xml file for mysql database and hibernate
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="{{NAME}}">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/{{DBNAME}}"/>
<property name="javax.persistence.jdbc.user" value="{{DBUSER}}"/>
<property name="javax.persistence.jdbc.password" value="{{DBPWD}}"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
@cybrown
cybrown / pom.xml
Created December 3, 2013 16:24
pom.xml for jee, hibernate and mysql
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
@cybrown
cybrown / HistoryHandler.js
Created October 17, 2013 15:43
Javascript prototype to manage history via hash.
function HistoryHandler(pathname) {
this.hashes = [];
this.active = false;
var self = this;
this.pageregex = new RegExp(pathname.replace(/\//g, '\\/') + '$');
if (window.location.pathname.match(this.pageregex)) {
this.active = true;
$(window).on('hashchange', function (event) {
for (var i in self.hashes) {
var h = self.hashes[i];
@cybrown
cybrown / Gruntfile.js
Created October 12, 2013 12:56
Typescript gruntfile
var grunt = require('grunt');
grunt.loadNpmTasks('grunt-typescript');
grunt.initConfig({
typescript: {
base: {
src: ['path/to/typescript/files/**/*.ts'],
dest: 'where/you/want/your/js/files',
options: {
@cybrown
cybrown / inheritance.js
Created September 2, 2013 15:57
Javascript Prototype Inheritance
var Parent = function (arg1, arg2) {
// TODO Define instance members here...
};
Parent.prototype.doSomething = function (arg) {
// TODO Do something...
};
var Child = function (arg1, arg2) {
Parent.call(this, arg1, arg2) // Call to super constructor