Skip to content

Instantly share code, notes, and snippets.

@adilmezghouti
adilmezghouti / OmnitureTagger.js
Created March 13, 2018 20:47
Collect and push omniture tags
/**
* This function allows you to add a number of omniture tags and once they are all assigned non-empty values,
* they will be automatically submitted to the server
* @returns {{addTag: addTag, updatedTag: updatedTag}}
* @constructor
*/
var OmnitureTagger = function() {
var tags = {};
for (var i=0;i < arguments.length;i++) {
@adilmezghouti
adilmezghouti / JayToken.sol
Created February 27, 2018 15:16
ERC20 Loyalty Token - still needs some work
pragma solidity ^0.4.0;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
@adilmezghouti
adilmezghouti / ethereum-commands.sh
Last active March 12, 2018 21:32
useful commands to get the ethereum environment to work locally
//to run geth client
geth --datadir=./chaindata/ --rpccorsdomain "*" --rpc --rpcport "8585" --rpcaddr 0.0.0.0 -rpcapi="db,eth,net,web3,personal,web3"
//start the interactive geth shell
geth attach /Users/adilmezghouti/development/ether-lab/chaindata/geth.ipc
//make the geth command available system wide
export PATH="/Users/adilmezghouti/development/geth-alltools-darwin-amd64-1.7.2-1db4ecdc:$PATH"
//Initilaize the local ethereum node
@adilmezghouti
adilmezghouti / web3-example.js
Created February 27, 2018 15:08
web3 example
//Loading files dynamically
function loadjscssfile(filename, filetype){
if (filetype=="js"){ //if filename is a external JavaScript file
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
}
else if (filetype=="css"){ //if filename is an external CSS file
var fileref=document.createElement("link")
@adilmezghouti
adilmezghouti / OmnitureTagger.js
Created February 22, 2018 17:50
Omniture Tagger using MutationObserver
/**
* This function allows you to add a number of omniture tags and once they are all assigned non empty values,
* they will be automatically submitted to the server
* @returns {{addTag: addTag, updatedTag: updatedTag}}
* @constructor
*/
var OmnitureTagger = function() {
var tags = {};
for (var i=0;i < arguments.length;i++) {
@adilmezghouti
adilmezghouti / poo.java
Last active December 28, 2021 22:56
POO
abstract class Forme {
protected String couleur;
public void changerCouleur(String nouveauCouleur){
this.couleur = nouveauCouleur;
}
protected abstract void deplacer(float dx, float dy);
}
@adilmezghouti
adilmezghouti / reflection_and_deletion.js
Last active August 29, 2015 13:59
Javascript Beginner's series - Objects
//Reflection
//"typeof" does it for you
console.log(typeof flight.number); // 'number'
console.log(typeof flight.arrival); // 'object'
console.log(typeof flight.manifest); // 'undefined'
console.log(typeof flight.toString); // 'function'
console.log(typeof flight.constructor); // 'function'
/*
If you would like to access an object property and want the value of the child not the parent's, you can use "hasOwnProperty"
@adilmezghouti
adilmezghouti / creation_and_handling_of_objects.js
Last active August 29, 2015 13:59
Javascript Beginner's series - Objects
var flight = {
airline: "Oceanic",
number: 815,
//you can have nested objects
departure: {
IATA: "SYD",
time: "2004-09-22 14:55",
city: "Sydney"
},
arrival: {
@adilmezghouti
adilmezghouti / useful_unix_commands
Last active August 29, 2015 13:58
Useful unix commands
#To check which programs are running on which ports
sudo lsof -i :80 # checks port 80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
haproxy 32850 root 4u IPv4 0xf27d639a63f41339 0t0 TCP *:http (LISTEN)
#To watch changes to a given folder
#To install this command on mac check out this link: http://osxdaily.com/2010/08/22/install-watch-command-on-os-x
watch -d ls -l