Skip to content

Instantly share code, notes, and snippets.

View johanbove's full-sized avatar
💭
Semper meliorem facio

Johan Bové johanbove

💭
Semper meliorem facio
View GitHub Profile
@johanbove
johanbove / longrunningtasks.js
Created June 2, 2015 12:25
Unblocking the browser while long processes run using setTimeout or requestAnimationFrame
var hasRequestAnimationFrame = (window.requestAnimationFrame) ? true : false,
updateProgress = function (percent) {
$progress.text((percent < 100) ? percent.toFixed(2) + "%" : 100 + "%");
},
// @see http://stackoverflow.com/questions/672732/prevent-long-running-javascript-from-locking-up-browser
doCalculation = function () {
//do your thing for a short time
@johanbove
johanbove / favtweets.js
Last active August 29, 2015 14:22
Tweetledee JavaScript implementation Twitter tweets output
/*jslint browser: true, nomen: true */
/*global $, console */
$(function () {
"use strict";
// @see http://stackoverflow.com/a/14880260
String.prototype.replaceBetween = function (start, end, what) {
return this.substring(0, start) + what + this.substring(end);
};
@johanbove
johanbove / Access-Control-Allow-Origin.txt
Created June 3, 2015 14:14
htaccess commands to set "Access-Control-Allow-Origin"
#Header add Access-Control-Allow-Origin "http://domain.com"
#Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
#Header add Access-Control-Allow-Methods "GET, POST, DELETE, OPTIONS"
#Header add Access-Control-Allow-Methods "GET, POST"
SetEnvIf Origin "^http(s)?://(.+\.)?(domain\.org|domain2\.com)$" origin_is=$0
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
@johanbove
johanbove / yeoman-jekyll-gitignore
Created June 4, 2015 11:36
gitignore for Yeoman-Jekyll projects
# .gitignore for Yeoman-Jekyll projects
# Ignore hidden folders #
# This takes care of .tmp, .sass-cache, and many others #
.*/
# Ignore OS generated files #
.DS_Store*
ehthumbs.db
Icon?
@johanbove
johanbove / workspace.bat
Last active August 29, 2015 14:22
Opens up a specific workspace folder for me quickly from the Windows command line
REM Take me to a specific workspace folder
echo off
set project=%1
set thepath=".\Dropbox\%USERNAME%\workspace\active\%project%"
echo Hi %USERNAME%, getting project %thepath% for you...
cd %thepath%
REM ``ls`` only works when cygwin is installed, otherwise ``dir`` will do
call ls
@johanbove
johanbove / setchcp.bat
Created June 6, 2015 09:15
Set active code page to UTF-8
call chcp 65001
@johanbove
johanbove / liquidblockswithcolcount.liquid
Last active August 29, 2015 14:22
liquid template blocks with columns
{% for block in site.data.[site.lang].general.footer.blocks %}
{% assign colCount = forloop.length | plus: 1 %}
{% assign colWidth = 12 | divided_by: colCount %}
<div class="col-md-{{ colWidth }} col-xs-6">
<h5>{{ block.title }}</h5>
<ul>
{% if block.links != empty %}
{% for linkElement in block.links %}
<li><a href="{% if linkElement.permalink != null %} {{ linkElement.permalink | prepend: site.baseurl }} {% else %} {{ linkElement.link }} {% endif %}" {% if linkElement.link != null %}target="_blank"{% endif %}>{{ linkElement.text }}</a></li>
{% endfor %}
@johanbove
johanbove / parseCSV.js
Last active August 29, 2015 14:22
Parsing text file to JS loaded through ajax request
// @see http://www.amcharts.com/tutorials/loading-external-data/
/*
2011-02-23,133034
2011-02-24,122290
2011-02-25,383603
2011-02-28,125285
2011-03-01,118042
2011-03-02,102500
2011-03-03,434047
@johanbove
johanbove / git_commit_emotijis.markdown
Last active August 29, 2015 14:24
Git commit emojis

Work hard, play hard! Consider prefixing your commit messages with a relevant emoji for great good. source

  • 🎨 :art: when improving the format/structure of the code
  • 🐎 :racehorse: when improving performance
  • 🚱 :non-potable_water: when plugging memory leaks
  • 📝 :memo: when writing docs
  • 🐧 :penguin: when fixing something on Linux
  • 🍎 :apple: when fixing something on Mac OS
  • 🏁 :checkered_flag: when fixing something on Windows
  • 🐛 :bug: when fixing a bug
@johanbove
johanbove / fizzbuzz_1.js
Last active August 29, 2015 14:24
Fizzbuzz
// Inspired by http://c2.com/cgi/wiki?FizzBuzzTest
/*
"Write a program that prints the numbers from 1 to 100.
But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”.
For numbers which are multiples of both three and five print “FizzBuzz”."
*/