Skip to content

Instantly share code, notes, and snippets.

@cupuyc
cupuyc / gist:1213922
Created September 13, 2011 14:25
kickFms replacements
//fasade.asc
// First place that accept incoming RPC from client side.
// ---------------------------------------------------------------------------------
Client.prototype.__resolve = function(ctype) {
// Check if a component class corresponding to ctype exists if so
// return a new facade factory for ctype components
if ( gFrameworkFC.components[ctype] != null )
return this[ctype] = new FCFactory(this, ctype);
// else do nothing, forcing a NetConnection.Call.Failed
@cupuyc
cupuyc / facade.as
Created September 23, 2011 09:04
From scriptlib
Client.prototype.__resolve = function(ctype) {
// Check if a component class corresponding to ctype exists if so
// return a new facade factory for ctype components
if ( gFrameworkFC.components[ctype] != null ) {
info("Create new factory for type:" + ctype);
return this[ctype] = new FCFactory(this, ctype);
}
// else do nothing, forcing a NetConnection.Call.Failed
}
@cupuyc
cupuyc / UIUtil.as
Created October 29, 2014 17:29
Camera rotation
/**
* Get camera rotation to keep video shown properly.
* Video object attached to the camera will only show upright video in a landscape-aspect orientation.
* For iOS default orientation is not landscape.
* For Android it varies.
*/
public static function getCameraRotation(camera : Camera) : int {
if (isLandscapeOrientation()) {
// camera is OK in landscape
return 0;
@cupuyc
cupuyc / java8.sh
Last active February 27, 2021 18:46
Install Java8 Ubuntu
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install maven
sudo apt-get install git
sudo apt-get install npm
sudo npm install -g bower
sudo ln -s /usr/bin/nodejs /usr/bin/node
@cupuyc
cupuyc / jquery.terminal-0.8.8_custom.js
Created August 17, 2016 12:59
Jquery terminal patched to have copy pasting working on Win/Mac FF/Chrome
/**@license
* __ _____ ________ __
* / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 0.8.8
* http://terminal.jcubic.pl
*
* Licensed under GNU LGPL Version 3 license
@cupuyc
cupuyc / DAO.sol
Last active January 20, 2017 10:15
DAO-contract-MainETH
/*
This file is part of the DAO.
The DAO is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The DAO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
//sol Wallet
// Multi-sig, daily-limited account proxy/wallet.
// @authors:
// Gav Wood <g@ethdev.com>
// inheritable "property" contract that enables methods to be protected by requiring the acquiescence of either a
// single, or, crucially, each of a number of, designated owners.
// usage:
// use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by
// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
// interior is executed.
@cupuyc
cupuyc / latency.txt
Created March 11, 2017 15:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@cupuyc
cupuyc / puzzle.md
Last active April 10, 2017 12:24
Misspelled lookups: a Grammarly coding puzzle (6 days duration)

Misspelled lookups

Given two strings, S1 and S2, we can define an edit distance as the minimum number of operations required to change S1 to S2.

The operations might be one of the following:

  • delete a character
  • insert a character
  • substitute a character for another character
@cupuyc
cupuyc / LetsEncrypt.md
Created November 29, 2017 14:00 — forked from davestevens/LetsEncrypt.md
Let’s Encrypt setup for Apache, NGINX & Node.js

Let's Encrypt

Examples of getting certificates from Let's Encrypt working on Apache, NGINX and Node.js servers.

Obtain certificates

I chose to use the manual method, you have to make a file available to verify you own the domain. Follow the commands from running

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt