Skip to content

Instantly share code, notes, and snippets.

Matías Herranz matiasherranz

Block or report user

Report or block matiasherranz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fb3.sh
$ git checkout feature/my-feature
$ git rebase -i master
$ git checkout master
$ git merge --no-ff feature/my-feature
$ git push origin master
$ git branch -d feature/my-feature
View fb2.sh
$ git checkout feature/my-feature
$ git rebase -i master
$ git checkout master
$ git merge --ff-only feature/my-feature
$ git push origin master
$ git branch -d feature/my-feature
View create_fb.sh
$ git checkout -b feature/my-feature master
@matiasherranz
matiasherranz / demo.html
Last active Sep 22, 2017
On this gist I implemented a full demo / proof-of-concept for the Page Visibility API + Vanilla JS DOM ready implementation.
View demo.html
<!--
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
-->
<html>
<head>
<title>Aloha!</title>
<script>
// START OF: VanillaJS implementation for DOM ready
window.readyHandlers = [];
window.ready = function ready(handler) {
View generate_uuid.js
function generateUUID() {
let d = new Date().getTime();
if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
d += performance.now(); //use high-precision timer if available
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
let r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
@matiasherranz
matiasherranz / parse_error_codes.js
Last active Jun 2, 2017
Full set of error codes for ParseJS
View parse_error_codes.js
/**
* Parse JavaScript SDK v1.9.2
*
* The source tree of this library can be found at
* https://github.com/ParsePlatform/Parse-SDK-JS
*/
View squash.sh
# Create a branch to play safe in
--> (git: master m) $ git checkout -b rebase_example
Switched to a new branch 'rebase_example'
# Create a file
--> (git: rebase_example m) $ touch some_file.txt
# Add it to git
--> (git: rebase_example ? m) $ git add some_file.txt
View maximize.py
import numpy as np
import pulp
# create the LP object, set up as a maximization problem
prob = pulp.LpProblem('Giapetto', pulp.LpMaximize)
# set up decision variables
soldiers = pulp.LpVariable('soldiers', lowBound=0, cat='Integer')
trains = pulp.LpVariable('trains', lowBound=0, cat='Integer')
View minimize2.py
import numpy as np
from scipy.optimize import minimize
w0 = 0
w1 = 0
w2 = 0
w3 = 0
ws = np.array([w0, w1, w2, w3])
View minimize.py
from numpy import array, sum as npsum
from scipy.optimize import minimize
cons = (
{'type': 'ineq', 'fun': lambda x: array([25 - 0.2 * x[0] - 0.4 * x[1] - 0.33 * x[2]])},
{'type': 'ineq', 'fun': lambda x: array([130 - 5 * x[0] - 8.33 * x[2]])},
{'type': 'ineq', 'fun': lambda x: array([16 - 0.6 * x[1] - 0.33 * x[2]])},
{'type': 'ineq', 'fun': lambda x: array([7 - 0.2 * x[0] - 0.1 * x[1] - 0.33 * x[2]])},
{'type': 'ineq', 'fun': lambda x: array([14 - 0.5 * x[1]])},
{'type': 'ineq', 'fun': lambda x: array([x[0]])},
You can’t perform that action at this time.