Skip to content

Instantly share code, notes, and snippets.

View anaibol's full-sized avatar

Anibal anaibol

View GitHub Profile
@Andreyco
Andreyco / [LESS] Positioning mixins
Last active March 10, 2016 09:56
Positioning mixins similar to those ones in Stylus.
/**
* Set positioning properties (top|right|bottom|left).
* @param prop-value. String in format "top 10px".
*/
.positioning-property(@prop-value) {
@property: extract(@prop-value, 1);
@value: extract(@prop-value, 2);
@{property}: @value;
}
@DmitrySoshnikov
DmitrySoshnikov / expression-only.md
Last active April 16, 2016 12:00
ES: Expression only

"Everything is an expression"... since ES1?

Many languages support "expression-only" semantics, allowing to use any construct in an expression position.

NOTE: the difference between expressions and statements is that the former produce a value, while the later don't.

For example, Ruby's if-expression:

x = 10
@wtfaremyinitials
wtfaremyinitials / promise-polyfill.js
Last active May 7, 2016 10:43
Feature detecting Promise polyfill
if(!window.Promise) {
var req = new XMLHttpRequest();
req.open('GET', 'https://cdn.polyfill.io/v2/polyfill.min.js?features=Promise', false);
req.send();
eval(req.responseText);
}
@sjwilliams
sjwilliams / imgix_purge_node.js
Created May 3, 2016 23:23
Purging Imgix CDN with node.js
var Curl = require( 'node-libcurl' ).Curl;
var querystring = require( 'querystring' );
var IMGIX_API_KEY = '';
function imgixPurge(url){
var curl = new Curl();
curl.setOpt(Curl.option.URL, 'https://api.imgix.com/v2/image/purger');
curl.setOpt('HTTPAUTH', Curl.auth.BASIC);
curl.setOpt(Curl.option.USERNAME, IMGIX_API_KEY);
curl.setOpt(Curl.option.TIMEOUT, 20);
@matthiasg
matthiasg / haproxy.cfg
Created August 9, 2016 19:29 — forked from ryzy/haproxy.cfg
HAProxy - essentials for HTTP/2
frontend https-in
mode tcp
bind *:443 ssl crt /etc/ssl/dummy.pem alpn h2,http/1.1
use_backend nodes-http2 if { ssl_fc_alpn -i h2 }
default_backend nodes-http
backend nodes-http
server node1 web.server:80 check
backend nodes-http2
@alvaropinot
alvaropinot / map-to-object.js
Created October 3, 2017 17:58
"FUNctional" 😜 Map 🗺 to object 🔑
const obj = { a: 1, c: 3, b: 2 }
// Map from object.
const myMap = new Map(Object.entries(obj))
// Map to Object.
// NOTE: Keys will be cast to strings by `.toString`, so any "complex" key like for example `[1, 2]` will become `1,2`
const newObj = [...myMap.entries()]
.reduce((acc, [key, value]) => (Object.assign(acc, { [key]: value })), {})
@irazasyed
irazasyed / FBFeedShare.md
Last active February 12, 2018 13:05
Facebook Dialog feed share example with all the properties and using YouTube App!

Learn more about Sharing Best Practices for better understanding.

V1: This version has properties but the output would be with numeric keys, Example (Google, Bing and Yahoo are the Hyperlinks/Clickable):

1: Google
2: Bing
3: Yahoo
@algorithmcardboard
algorithmcardboard / placeholder.js
Last active September 14, 2018 18:12
Angularjs Placeholder directive. Placeholder text is removed on first input rather than focus
(function(angular, app) {
"use strict";
app.directive('placeholder',["$document", "$timeout", function($document, $timeout){
var link = function(scope,element,attrs,ctrl){
// if you dont use modernizr library use the solution given at
// http://stackoverflow.com/questions/5536236/javascript-check-for-native-placeholder-support-in-ie8
// to check if placeholder is supported natively
if(Modernizr.input.placeholder){
return;
@tkadlec
tkadlec / perf.js
Created April 23, 2015 11:54
Super simple example of adding perf timing to the page display during dev work
(function () {
var perfBar = function(budget) {
window.onload = function() {
window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
var timing = window.performance.timing,
now = new Date().getTime(),
output, loadTime;
@dan-dr
dan-dr / index.html
Last active September 20, 2019 01:09
Netlify formData object from value
<form>
<input type="text" name="cities[]" /> <!-- for arrays and objects. don't enumerate/propertize in markup. yes i just invented propertize -->
</form>