Skip to content

Instantly share code, notes, and snippets.

View anasnakawa's full-sized avatar
💭
I may be slow to respond.

Anas Nakawa anasnakawa

💭
I may be slow to respond.
View GitHub Profile
@gr2m
gr2m / account_dreamcode.js
Last active May 7, 2022 08:22
Imagine the typical backend tasks for user authentication would exist right in the browser. How would the code look like? This is what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
// sign up
account.signUp('[email protected]', 'secret');
// sign in
account.signIn('[email protected]', 'secret');
// sign in via oauth
account.signInWith('twitter');
// sign out
@sukima
sukima / XORCipher.js
Last active December 21, 2024 03:07
A Super simple encryption cipher using XOR and Base64 in JavaScript
// XORCipher - Super simple encryption using XOR and Base64
//
// Depends on [Underscore](http://underscorejs.org/).
//
// As a warning, this is **not** a secure encryption algorythm. It uses a very
// simplistic keystore and will be easy to crack.
//
// The Base64 algorythm is a modification of the one used in phpjs.org
// * http://phpjs.org/functions/base64_encode/
// * http://phpjs.org/functions/base64_decode/
@anasnakawa
anasnakawa / media-query.scss
Last active December 19, 2015 08:29
generic media query mixin
// ------------------------------
// generic media query mixin
// ------------------------------
// author: Anas Nakawa
// license: MIT
// ------------------------------
// table of content
// ------------------------------
// media-compact-retina (private)
// media-conpact-normal (private)
@anasnakawa
anasnakawa / coffeescript-extend.js
Last active December 22, 2015 05:18
OOP in javascript extracted from CoffeeScript
// tiny JavaScript inheritance
// extracted from CoffeeScript
//
// * **param:** {Class} child
// * **param:** {Class} parent
var extends = function( child, parent ) {
for ( var key in parent ) {
if ( {}.hasOwnProperty.call( parent, key ) ) {
child[ key ] = parent[ key ];
}
@FLasH3r
FLasH3r / clearfix_v1.css
Last active November 23, 2016 12:58
clearfix variations (with original source link)
/*
* source: http://nicolasgallagher.com/micro-clearfix-hack/
*/
.clearfix:before, .clearfix:after { content: " "; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
@addyosmani
addyosmani / examples.md
Last active February 23, 2016 18:22
Object.observe() examples from my talk

What are we trying to observe? Raw object data.

// Objects
var obj = { id: 2 };
obj.id = 3; // obj == { id: 3 }
 
// Arrays
var arr = ['foo', 'bar'];
arr.splice(1, 1, 'baz'); // arr == ['foo', 'baz'];
@anasnakawa
anasnakawa / wrapper.js
Created October 20, 2013 07:17
AMD / CommonJs (NodeJs) / Browser wrapper pattern
// AMD / Common Js / Browser Wrapper pattern
// copyright to [millermedeiros](https://github.com/millermedeiros/js-signals/blob/master/src/wrapper.js)
// ---------------------------------
(function(global){
var libName;
// define your library
//exports to multiple environments
if(typeof define === 'function' && define.amd){ //AMD
@gka
gka / country-names.json
Created November 26, 2013 10:30
Recognized country names
{
"en": {
"AD": "Andorra",
"AE": "United Arab Emirates",
"AF": "Afghanistan",
"AG": "Antigua and Barbuda",
"AI": "Anguilla",
"AL": "Albania",
"AM": "Armenia",
"AN": "Netherlands Antilles",
@hemanth
hemanth / Gruntfile.js
Created December 31, 2013 14:13
grunt vs gulp
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: ['src/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
@anasnakawa
anasnakawa / tiniest-wrapper.js
Last active January 4, 2016 00:09
the tiniest module wrapper for CommonJs / AMD and the browser
// Tiniest Module Wrapper - (c) Anas Nakawa - <anas.nakawa {at} gmail.com>
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function() {
function myLibrary() {};
// CommonJs / Node
( typeof module !== "undefined" && module.exports && ( module.exports = myLibrary ) ) ||
// AMD / RequireJs
( typeof define !== "undefined" && !define(function() { return myLibrary; }) ) ||
// browser
( typeof window !== "undefined" && ( window.myLibrary = myLibrary ) );