Skip to content

Instantly share code, notes, and snippets.

View manfromanotherland's full-sized avatar
🤏

Edmundo Santos manfromanotherland

🤏
View GitHub Profile
@sybrew
sybrew / search-canonical-push-for-ga.php
Last active April 25, 2019 17:53
Search Canonical Push for Google Analytics
<?php
/**
* Plugin Name: Search Canonical Push for Google Analytics
* Plugin URI: https://theseoframework.com/
* Description: This plugin adds a small script to Search archives that optimizes the Google Analytics script when using pretty Search links.
* Version: 1.0.1
* Author: Sybre Waaijer
* Author URI: https://theseoframework.com/
* License: GPLv3
*/
@manfromanotherland
manfromanotherland / ffmpeg.sh
Created March 31, 2017 11:49
Optimise videos with ffmpeg
ffmpeg -i huge-file.mp4 -vcodec libx264 -preset veryfast smaller-file.mp4
@hoetmaaiers
hoetmaaiers / overview.md
Last active August 29, 2022 07:28
Webstorm live templates

React Native Live Templates for WebStorm

How to add Live Template in Webstorm

  1. open preferences
  2. editor> live templates
  3. add template group for React Native
  4. add templates below to the new group
  5. define context > javascript
  6. edit variables > add "fileNameWithoutExtension" to "$fnName$"
@orther
orther / index.js
Created January 27, 2017 17:34
A few simple examples of sorting with Ramda's sortBy function.
import R from 'ramda';
const items = [
{id: 1, name: 'Al', country: 'AA'},
{id: 2, name: 'Connie', country: 'BB'},
{id: 3, name: 'Doug', country: 'CC'},
{id: 4, name: 'Zen', country: 'BB'},
{id: 5, name: 'DatGGboi', country: 'AA'},
{id: 6, name: 'Connie', country: 'AA'},
];
@electerious
electerious / toClassString.js
Created January 21, 2017 15:48
Conditionally convert the keys of an object to a string of class names
const toClassString = (obj) => Object.keys(obj).filter((key) => obj[key]===true).join(' ').trim()
@electerious
electerious / formatNumber.js
Created September 30, 2016 10:47
Format a number
const formatNumber = (num, delimiter = ',') => num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, delimiter)
@hyamamoto
hyamamoto / string.hashcode.js
Created September 30, 2016 07:19
JavaScript Implementation of String.hashCode() .
/**
* Returns a hash code for a string.
* (Compatible to Java's String.hashCode())
*
* The hash code for a string object is computed as
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* using number arithmetic, where s[i] is the i th character
* of the given string, n is the length of the string,
* and ^ indicates exponentiation.
* (The hash value of the empty string is zero.)
@Rich-Harris
Rich-Harris / service-workers.md
Last active August 5, 2025 07:38
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@denlunev
denlunev / gist:a34a1eb3308913c3ca28b6e3d7b7ba1d
Created June 19, 2016 12:58
Execute code after HubSpot form submit
hbspt.forms.create({
...
onFormReady: function($form, ctx) {
$form.submit(function(){
//synchronous delay
HSPopup.pause(300);
//Your code goes here
const hasTouchscreen = () => {
const mobileDevice = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera)
const onTouchEnd = ('ontouchend' in document.documentElement)
return (mobileDevice && onTouchEnd)
}