Skip to content

Instantly share code, notes, and snippets.

View tsbits's full-sized avatar
👾

Olivier Destenay tsbits

👾
View GitHub Profile
@jjgrainger
jjgrainger / Vector.js
Last active May 27, 2023 22:59
A simple Vector class in javascript
var Vector = function(x, y) {
this.x = x || 0;
this.y = y || 0;
};
// return the angle of the vector in radians
Vector.prototype.getDirection = function() {
return Math.atan2(this.y, this.x);
};
@Fonserbc
Fonserbc / SwipeInput.cs
Last active April 27, 2023 04:28
A simple swipe detector for touchscreens for Unity3D. Four cardinal directions.
using UnityEngine;
/*
* Swipe Input script for Unity by @fonserbc, free to use wherever
*
* Attack to a gameObject, check the static booleans to check if a swipe has been detected this frame
* Eg: if (SwipeInput.swipedRight) ...
*
*
*/
@alexpchin
alexpchin / socket-cheatsheet.js
Created December 15, 2015 16:58
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@ssskip
ssskip / ISO3166-1.alpha2.json
Last active June 18, 2024 07:36
json of country codes (ISO 3166-1 alpha-2) and corresponding names
{
"AF": "Afghanistan",
"AX": "Aland Islands",
"AL": "Albania",
"DZ": "Algeria",
"AS": "American Samoa",
"AD": "Andorra",
"AO": "Angola",
"AI": "Anguilla",
"AQ": "Antarctica",

Platform

cordova platform add ios

Build

cordova build

Emulate

cordova emulate ios

Plugin

@Silfen
Silfen / Sharer.md
Last active January 3, 2016 23:49
Sharer

Twitter

http://twitter.com/share?text={description}&url={url}&hashtags={hashtags}

Facebook

http://www.facebook.com/share.php?u={url}

Pinterest

http://pinterest.com/pin/create/button/?url={url}&media={picture_url}&description={description}

Tumblr

http://www.tumblr.com/share/link?url={url}&name={name}&description={description}

@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@Silfen
Silfen / gist:5598245
Last active December 17, 2015 10:58
Git reminder

Creer un projet

git init

Cloner un projet

git clone http://abc.git

Afficher le status des fichiers

@pvanneau
pvanneau / .htaccess
Last active December 17, 2015 10:49
Routing tools for webapp (like Backbone)
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}