Skip to content

Instantly share code, notes, and snippets.

View cesarvr's full-sized avatar
:electron:
compiling...

Cesar Valdez cesarvr

:electron:
compiling...
View GitHub Profile
@cesarvr
cesarvr / OpenSimplexNoise.java
Created November 3, 2015 06:22 — forked from KdotJPG/OpenSimplex2S.java
Visually axis-decorrelated coherent noise algorithm based on the Simplectic honeycomb.
/*
* OpenSimplex Noise in Java.
* by Kurt Spencer
*
* v1.1 (October 5, 2014)
* - Added 2D and 4D implementations.
* - Proper gradient sets for all dimensions, from a
* dimensionally-generalizable scheme with an actual
* rhyme and reason behind it.
* - Removed default permutation array in favor of
$ export JAVA_HOME=/jdk/location/ #finish with / is important here, there is a bug in the installer
$ npm install ella
@cesarvr
cesarvr / perf_install.sh
Created June 6, 2017 15:38
Installing perf in Archlinux/Fedora
#install perf in Archlinux
sudo pacman -Sy perf
#install perf in Fedora
sudo dnf install perf
@cesarvr
cesarvr / bijection.js
Created July 25, 2017 15:57
take two sets and returns a elements than differ in frequency.
function freq(acc, next){
if(acc[next] === undefined)
acc[next] = 1;
else
acc[next] += 1;
return acc
}
@cesarvr
cesarvr / perf.sh
Last active August 28, 2017 14:55
using Linux performance tool
perf record -F 99 -p `pgrep -n node` 
# Example:
# F is the sampling frequency in hertz.
# p is the proccess ID (PID).
# Example: pgrep -n node >> 1801 << returning the PID of a process called node.
@cesarvr
cesarvr / native.sh
Created August 30, 2017 09:25
Creating ready native node module...
mkdir hello && cd hello # creating your workspace
npm init # this will create a package.js
npm install nan@latest --save # this give native headers nan.h, that wraps and adapts different version of v8.h
sudo npm install node-gyp -g # this install the building command to compile your native addon.
@cesarvr
cesarvr / hello.cc
Created August 30, 2017 10:20
Hello World add-on for Nodejs
#include <nan.h>
using namespace v8;
using namespace Nan;
void addWorld(const FunctionCallbackInfo<Value>& info) {
info.GetReturnValue().Set(New("world").ToLocalChecked());
}
void Init(Local<Object> exports) {
@cesarvr
cesarvr / binding.gyp
Last active September 5, 2017 09:39
just an example binding.gyp
{
"targets": [{
"target_name": "hello",
"sources": ["src/hello.cc"],
"include_dirs": [
"node_modules/nan"
],
"cflags": ["-std=c++11", "-Wall", "-pedantic"]
}]
@cesarvr
cesarvr / Push Notification.ts
Last active October 10, 2017 11:09
Simple Push Notification Class Using Aerogear-Push-Notification
import * as $fh from 'fh-js-sdk';
import _ from 'underscore';
export class PushNotification {
constructor(pushConfiguration) {
$fh.push(this.handleNotification.bind(this),
this.registration,
this.registrationError,
pushConfiguration
@cesarvr
cesarvr / internal.js
Created October 28, 2017 05:12
Transforming an internal cordova HTML file template to PDF
//Example: file:///android_asset/index.html
function printInternalFile(param) {
/* generate pdf using url. */
if(cordova.platformId === 'ios') {
// To use window.resolveLocalFileSystemURL, we need this plugin https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/
// You can add this by doing cordova plugin add cordova-plugin-file or