Skip to content

Instantly share code, notes, and snippets.

View vinicius33's full-sized avatar
:shipit:
“You get what you git push”

Vinicius Souza vinicius33

:shipit:
“You get what you git push”
View GitHub Profile
@SlexAxton
SlexAxton / jConstruct.js
Created December 22, 2011 20:20
jQuery constructor recreation attempt
(function (window, undefined) {
var MRTN = (function() {
// The main FeedTheWebDev function
var MRTN = function(element) {
return new MRTN.fn.init(element, rootDoc);
},
// Ref to root document
rootDoc;
@brandonaaskov
brandonaaskov / jQuery Change Event: Proper Binding
Created January 11, 2012 21:34
jQuery's change() event doesn't work as expected with input text fields. This, however, does work.
/*
For some reason, the change() event only fires when the input field loses focus.
Binding to other options ('change keypress paste focus textInput input') will
fire the event several times, which is bad. The below code works even when
content is pasted into the text field, and only fires once as expected.
*/
$('#search-form .term').bind('input', function(){
console.log('this actually works');
});
@SlexAxton
SlexAxton / safeForEach.js
Created April 23, 2012 22:57
Safe forEach in JavaScript
Array.prototype.safeForEach = function ( fn ) {
var len = this.length;
for ( var cur = 0, cur < len; ++cur ) {
for ( var i = 0; i < len; ++i ) {
if ( this.hasOwnProperty[ i ] ) {
if ( i === cur ) {
fn && fn( this[ i ], i, this );
}
}
}
@ajaxray
ajaxray / cookies.js
Created November 24, 2012 12:01
Small JavaScript class to help create, read and delete cookie.
/**
* Cookies - A small class to manipulate cookies from javascript
*
* Compressed version: https://gist.github.com/4147384
*
* @see www.quirksmode.org/js/cookies.html
* @author Anis uddin Ahmad <[email protected]>
*/
window.Cookies = {
@badsyntax
badsyntax / gist:4330899
Last active November 14, 2022 22:54
Googe places autocomplete implementation using Twitter bootstrap typeahead and google's autocomplete and geocoding services
/**
* Author: Richard Willis - badsyntax.co
* Example here: http://demos.badsyntax.co/places-search-bootstrap/example.html
*
* Please note: This is not a reliable method of geocoding the address. Using the
* PlacesService is a much better approach. View the example above for an example
* of using the PlacesService to geocode the address.
*/
var service = new google.maps.places.AutocompleteService();
@singhshivam
singhshivam / Immutable JS Examples
Last active August 5, 2023 19:16
Immutable JS Examples
List()
var list = Immutable.List([1,2,3])
// [1, 2, 3]
List.isList()
Immutable.List.isList(list)
// true
List.of()
var list = Immutable.List.of(1,2,3);