Skip to content

Instantly share code, notes, and snippets.

View lionelB's full-sized avatar
🪂
Working from home

Lionel lionelB

🪂
Working from home
View GitHub Profile
@mihow
mihow / load_dotenv.sh
Last active June 14, 2024 02:15
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@revolunet
revolunet / cordova-tips.md
Last active August 10, 2022 22:44
Cordova iOS tips

General

  • create a single page javascript application
  • be as low-level as possible to be able to control performance (=minimize layers)
  • masterize your dev/build environnement so you can work/play nicely

Debug apps

  • Open safari console in development menu with simulator or attached devices (enable debug in ipad/safari dev options)
  • debug your app from xcode to get native debugger and performance metrics
@MoOx
MoOx / svgicon.css
Last active December 3, 2018 08:50
Svg icons with React.js with webpack loader (svg: raw-loader)
.SVGIcon {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
/* fix webkit/blink poor rendering issues */
transform: translate3d(0,0,0);
/* it's better defined directly because of the cascade shit
width: inherit;
height: inherit;
function throttle(fn, duration){
var lastCall = new Date().getTime() // closure variable
, timeout = null
duration = parseInt(duration, 10) // convert duration to int
function throttled(){
var currentCall = new Date().getTime()
, gap = currentCall - lastCall
, self = this, args = arguments
@bloodyowl
bloodyowl / gist:5455880
Created April 24, 2013 21:51
Micro jQuery-like starter-kit for mobile development
;(function(){
var owns = {}.hasOwnProperty
, toString = {}.toString
, emptyArray = []
function arrayify(self, arr){
var i = 0, l = arr.length >> 0
for(;i < l; i++) self[i] = arr[i]
self.length = l
@bloodyowl
bloodyowl / gist:5282197
Last active December 15, 2015 15:29
139 bytes Cookie getter
/*
Returns document.cookie as an object
*/
function getCookie(o,a,l,s){o={},a=document.cookie.split(/\s*;\s*/),l=a.length;for(;l--;)s=a[l].split(/\s*=\s*/),o[s[0]]=s[1];return o}
Class.create({
// …
templates : {
item : $.create("article", {"class" : "item-article"})
, content : $.create("span")
}
, render : function(data){
var self = this, tmpl = self.templates
, fragment = Element.fragment()
@bloodyowl
bloodyowl / gist:4955668
Last active December 13, 2015 18:28
getCookie
function getCookie(){
var cookie = document.cookie
, regExp = /\s*([\w\-]+?)\s*=\s*([^;]*?)\s*(?:;|$)\s*/g
, obj = {}
cookie.replace(regExp, function(match, name, value){obj[name] = value})
return obj
}
@bloodyowl
bloodyowl / smoothScroll.js
Created June 29, 2012 09:52
smoothScroll explained
function (destination, duration) {
// destination (relative to window top) in px
// duration in ms
/* Variables */
var startPosition = "pageYOffset" in window ? window.pageYOffset : document.documentElement.scrollTop,
startTime = +new Date(),
endTime = startTime + duration,
// if top of element is outside the document, then define end point to document limit
// elsewhere, go the the top of the element
destinationSafe = document.height < (destination + window.innerHeight) ? document.height - window.innerHeight : destination,
@k33g
k33g / kind.js
Created April 2, 2012 20:29
Re Use Object Model of BackBone
// Just do this : (and include backbone.js)
var Kind = function() {
this.initialize && this.initialize.apply(this, arguments);
};
Kind.extend = Backbone.Model.extend
//Simpler
var Thing = function() {};
Thing.extend = Backbone.Model.extend