Skip to content

Instantly share code, notes, and snippets.

Ari auser

Block or report user

Report or block auser

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@auser
auser / LinkedListNode.js
Created Dec 11, 2018
Just saving this for myself... creating a linked list from a list of nodes.
View LinkedListNode.js
function LinkedListNode(v) {
this.val = v;
this.next = null
}
LinkedListNode.prototype.print = function() {
let node = this;
while (node) {
process.stdout.write(`${node.val} -> `)
node = node.next
View reverse_an_integer.js
/**
* @param {number} x
* @return {number}
*/
var reverse = function(x) {
let y = 0;
let num = Math.abs(x);
const intMax = Math.pow(2, 31) + 1;
while(num != 0) {
View simple-middleware.js
// Not the fastest thing in the world
export default class Middleware {
constructor (methods) {
this.methods = methods;
this.methodsStack = {};
this.originalMethod = {};
methods.forEach (method => {
this.methodsStack[method] = [];
this.originalMethod[method] = this[method];
View splitnum.js
const splitTotal = (total, n) => {
let arr = [];
let i = 0;
while (i < n) {
arr.push(Math.floor(Math.random() * total) + 1)
i++;
}
const sorted = [0].concat(arr, [total]).sort((a, b) => a - b);
let out = [];
@auser
auser / web3-solc-contract-compile-deploy.js
Created Mar 2, 2018 — forked from tomconte/web3-solc-contract-compile-deploy.js
Compiling and deploying an Ethereum Smart Contract, using solc and web3.
View web3-solc-contract-compile-deploy.js
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
// Connect to local Ethereum node
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// Compile the source code
const input = fs.readFileSync('Token.sol');
const output = solc.compile(input.toString(), 1);
View keras_model.py
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam
model = Sequential()
model.add(Dense(10, input_dim=X_train.shape[1], activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer=Adam(lr=0.01),
loss='binary_crossentropy',
View model.py
def nn(X, y, hiddenLayerSize=10, learningRate=0.01, epochs=100, debug=False):
m = X.shape[1]
outputSize = y.shape[1]
# Make our model
model = dict(
w0 = np.random.randn(m, hiddenLayerSize),
w1 = np.random.randn(hiddenLayerSize, outputSize)
)
View data.py
import numpy as np
import pandas as pd
np.random.seed(1)
# train comes from the titantic dataset provided by
# kaggle (https://www.kaggle.com/c/titanic/data)
df = pd.read_csv('./data/titanic-train.csv')
def preprocess(raw_data):
# Preprocess data
View blockstack
Verifying my Blockstack ID is secured with the address 14xYsyu9E2KocyoSUpByuJ6qZ7RSy3WcAv https://explorer.blockstack.org/address/14xYsyu9E2KocyoSUpByuJ6qZ7RSy3WcAv
View markdown-it-ignore-block.js
module.exports = function container_plugin(md, name, options) {
function validateDefault(params) {
return true;
// return params.trim().split(' ', 2)[0] === name;
}
function renderDefault(tokens, idx, _options, env, self) {
// add a class to the opening tag
if (tokens[idx].nesting === 1) {
tokens[idx].attrPush(['class', `${name} ignore-me`]);
You can’t perform that action at this time.