Skip to content

Instantly share code, notes, and snippets.

View esperancaJS's full-sized avatar
💭
investigating Deep Learning

Pedro Esperança esperancaJS

💭
investigating Deep Learning
View GitHub Profile
@JamieMason
JamieMason / es6-compose.md
Last active May 17, 2022 17:38
ES6 JavaScript compose function

ES6 JavaScript Compose Function

Definition

const compose = (...fns) =>
  fns.reduceRight((prevFn, nextFn) =>
    (...args) => nextFn(prevFn(...args)),
    value => value
 );
@Kcnarf
Kcnarf / .block
Last active May 23, 2024 14:54
D3-voronoi.clipCircle()
license: lgpl-3.0
@y0za
y0za / preact-redux-build-size.md
Last active January 11, 2018 11:34
preact redux build size

.babelrc

{
  "presets": ["es2015", "stage-0"],
  "plugins": [
    ["transform-react-jsx", { "pragma": "h" }],
    "transform-runtime"
  ]
}
function solution(A) {
//other shore bank
A.push(1);
//array with shortest paths for each leaf/bank
var reachable = [];
for(var i = 0; i<A.length; i++){
reachable.push(-1);
}
@esperancaJS
esperancaJS / TieRopes Codility Javascript 100%
Last active August 20, 2016 17:03
TieRopes Codility Javascript 100%
function solution(K, A) {
var possibleRopesCount = 0;
var fromPrev = 0;
for (var i = 0; i<A.length; i++){
if((fromPrev + A[i]) >= K){
possibleRopesCount++;
fromPrev = 0;
} else {
@esperancaJS
esperancaJS / gist:e09260d73dfe242859dc
Last active March 10, 2023 18:22
git merge –strategy=theirs (closest we can get)

##git merge –strategy=theirs (closest we can get)

get a temp copy of the branch you want to 'clone' into another

git checkout -b tmp <branch to copy from>

merge our version of the branch into the upstream with ours strategy

git merge --strategy=ours 
@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@ocolot
ocolot / url_shortener.coffee
Created July 23, 2013 12:50
Url Shortener (AngularJS service using Google UrlShortener API)
angular.module('AppServices')
.factory 'UrlShortener', ($q, $rootScope) ->
gapiKey = 'APP_KEY'
gapi_deferred = $q.defer()
gapi_loaded = gapi_deferred.promise
gapi.client.setApiKey(gapiKey)
gapi.client.load 'urlshortener', 'v1', ->
$rootScope.$apply ->
gapi_deferred.resolve('loaded')
@hendriklammers
hendriklammers / splitString.js
Last active January 6, 2024 15:46
Javascript: Split String into size based chunks
/**
* Split a string into chunks of the given size
* @param {String} string is the String to split
* @param {Number} size is the size you of the cuts
* @return {Array} an Array with the strings
*/
function splitString (string, size) {
var re = new RegExp('.{1,' + size + '}', 'g');
return string.match(re);
}