Skip to content

Instantly share code, notes, and snippets.

View bitsnaps's full-sized avatar
🌍
Working @ CorpoSense

Ibrahim H. bitsnaps

🌍
Working @ CorpoSense
View GitHub Profile
@rahulsom
rahulsom / Ele.groovy
Last active November 29, 2016 13:58
Mahout with Groovy - the faster way
@Grab(group = 'org.apache.mahout', module = 'mahout-core', version = '0.9')
import org.apache.mahout.cf.taste.impl.common.FastByIDMap
import org.apache.mahout.cf.taste.impl.common.FastIDSet
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel
import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender
import org.apache.mahout.cf.taste.impl.similarity.TanimotoCoefficientSimilarity
def mlDir = '/Users/rahulsomasunderam/Downloads/ml-100k'
def f = new File("$mlDir/u.data")
@akihiro4chawon
akihiro4chawon / Main.groovy
Created July 4, 2011 08:44
Memoization with Groovy Custom AST Tranformation
package akihiro4chawon
class Main {
@Memoize
def fib(a) {
//a <= 1 ? a : fib(a - 2) + fib(a - 1)
if (a <= 1) return a
else return fib(a - 2) + fib(a - 1)
}
JPEG2000 image files,00 00 00 0C 6A 50 20 20,JP2,Picture
3GPP multimedia files,00 00 00 14 66 74 79 70,3GP,Multimedia
MPEG-4 v1,00 00 00 14 66 74 79 70 69 73 6F 6D,MP4,Multimedia
3rd Generation Partnership Project 3GPP,00 00 00 14 66 74 79 70,3GG|3GP|3G2,Multimedia
Windows Disk Image,00 00 00 00 14 00 00 00,TBI,Windows
MPEG-4 video_1,00 00 00 18 66 74 79 70,3GP5|M4V|MP4,Multimedia
MPEG-4 video_2,00 00 00 1C 66 74 79 70,MP4,Multimedia
3GPP2 multimedia files,00 00 00 20 66 74 79 70,3GP,Multimedia
Apple audio and video,00 00 00 20 66 74 79 70 4D 34 41,M4A,Multimedia
3rd Generation Partnership Project 3GPP2,00 00 00 20 66 74 79 70,3GG|3GP|3G2,Multimedia
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
// We use the struct datatype to store the voter information.
struct voter {
address voterAddress; // The address of the voter
uint tokensBought; // The total no. of tokens this voter owns
uint[] tokensUsedPerCandidate; // Array to keep track of votes per candidate.
/* We have an array called candidateList initialized below.
Every time this voter votes with her tokens, the value at that
index is incremented. Example, if candidateList array declared
below has ["Rama", "Nick", "Jose"] and this
voter votes 10 tokens to Nick, the tokensUsedPerCandidate[1]
@coinables
coinables / example.html
Created June 20, 2017 03:01
coincap.io with socket.io example
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
</head>
<body>
<script type="text/javascript">
var socket = io.connect('http://socket.coincap.io');
socket.on('trades', function (tradeMsg) {
@AlwaysBCoding
AlwaysBCoding / decypher.js
Last active March 7, 2018 21:47
Ethereum Ðapp Development - Video 11 | Contract Inheritance
// Config
global.config = {
rpc: {
host: "localhost",
port: "8545"
}
}
// Load Libraries
global.solc = require("solc")
@AlwaysBCoding
AlwaysBCoding / crowdfund.sol
Created February 25, 2017 03:51
Ethereum Ðapp Development - Video 15 | The Block Gas Limit
contract CrowdFund {
address public beneficiary;
uint256 public goal;
uint256 public deadline;
struct Funder {
address addr;
uint256 contribution;
}
@AlwaysBCoding
AlwaysBCoding / script.js
Created March 3, 2017 03:28
Ethereum Ðapp Development - Video 18 | Signing Arbitrary Messages
// Private Key
var pKey = "..."
var pKeyx = new Buffer(pKey, "hex")
// Shared Message
var message = "..."
var messageHash = web3.sha3(message)
var messageHashx = new Buffer(messageHash.replace("0x", ""), "hex")
// Signed Hash
@AlwaysBCoding
AlwaysBCoding / install.txt
Created April 12, 2017 13:02
Ethereum Ðapp Development - Video 21 | Installing Geth
// Running on Ubuntu 16.04 (64-bit)
// Do this first
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
// Install Geth
sudo apt-get install ethereum
// Install Solc