Skip to content

Instantly share code, notes, and snippets.

contract MetaCoin {
mapping (address => uint) balances;
event Transfer(address _from,address _to, uint _amount);
function MetaCoin() {
balances[tx.origin] = 10000;
}
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
@mvaz
mvaz / ncp.py
Created May 4, 2016 22:48 — forked from panisson/ncp.py
Nonnegative Tensor Factorization, based on the Matlab source code available at Jingu Kim's home page: https://sites.google.com/site/jingukim/home#ntfcode Requires the installation of Numpy and Scikit-Tensor (https://github.com/mnick/scikit-tensor). For examples, see main() function.
# Copyright (C) 2013 Istituto per l'Interscambio Scientifico I.S.I.
# You can contact us by email (isi@isi.it) or write to:
# ISI Foundation, Via Alassio 11/c, 10126 Torino, Italy.
#
# This work is licensed under a Creative Commons 4.0
# Attribution-NonCommercial-ShareAlike License
# You may obtain a copy of the License at
# http://creativecommons.org/licenses/by-nc-sa/4.0/
#
# This program was written by Andre Panisson <panisson@gmail.com> at
@mvaz
mvaz / postgres-upgrade-recipe.sh
Created January 10, 2016 20:19 — forked from eoinkelly/postgres-upgrade-recipe.sh
Upgrade Postgres to 9.4 using Homebrew on Mac OSX
#!/bin/bash
# This script can be used in "run & hope" mode or you can use it as a recipe to
# do things manually - you probably want the latter if you really care about
# the data in your databases.
# Happy hacking
# /Eoin/
# Tell bash to stop if something goes wrong
set -e
@mvaz
mvaz / raspberry-pi-edimax-wifi-and-motion-sensor.md
Created December 8, 2015 09:44 — forked from eduardschaeli/raspberry-pi-edimax-wifi-and-motion-sensor.md
My notes on setting up a Raspberry Pi with an Edimax EW-7811UN WiFi Dongle and motion sensors

Raspberry Pi, WiFi and motion sensors

My notes on setting up a Raspberry Pi with an Edimax EW-7811UN WiFi Dongle and motion sensors.

We intend to use a few Raspberry Pis around the office, in order to find out if certain rooms are beeing used or not. For this, we need to get WiFi and a motion sensor working.

@mvaz
mvaz / lm_example
Created November 10, 2015 12:18 — forked from yoavg/lm_example
Unreasonable Effectiveness of LMs
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The unreasonable effectiveness of Character-level Language Models\n",
"## (and why RNNs are still cool)\n",
"\n",
"###[Yoav Goldberg](http://www.cs.biu.ac.il/~yogo)\n",
./elastic-mapreduce --create --alive \
--name "Hive cluster" \
--hive-interactive --hive-versions latest \
--hive-site=s3://${s3bucket}/emr/conf/hive-site.xml \
--ami-version latest \
--availability-zone us-east-1d --log-uri s3n://york-emr-logs \
--instance-group master --instance-type m1.medium --instance-count 1 --bid-price 0.175 \
--instance-group core --instance-type m1.large --instance-count 3 --bid-price 0.35 \
--enable-debugging --log-uri s3n://${s3bucket}/emr/logs \
--bootstrap-action s3://elasticmapreduce/bootstrap-actions/run-if \
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://d3js.org/d3.v2.js"></script>
<style>
line.arrow {
stroke: #666;
@mvaz
mvaz / df.py
Last active August 29, 2015 14:16 — forked from rxin/df.py
data = sqlContext.load("/home/rxin/ints.parquet")
data.groupBy("a").agg(col("a"), avg("num")).collect()
--
-- This is SQL query to extract AddressBook info from respective sqlite3 file from iOS backup.
-- It has been tested only on my own backup, so, if anything is wrong, fork, edit, and stuff.
--
-- # parse-manifest.py from http://stackoverflow.com/questions/3085153/how-to-parse-the-manifest-mbdb-file-in-an-ios-4-0-itunes-backup
--
-- $ python ../parse-manifest.py | grep AddressBook.sqlitedb
-- -rw-r--r-- 000001f5 000001f5 1654784 1312812502 1312812502 1287387943 (31bb7ba8914766d4ba40d6dfb6113c8b614be442)HomeDomain::Library/AddressBook/AddressBook.sqlitedb
--
-- $ sqlite3 31bb7ba8914766d4ba40d6dfb6113c8b614be442
#!/bin/bash
# Backs up the OpenShift PostgreSQL database for this application
# by Skye Book <skye.book@gmail.com>
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME