Skip to content

Instantly share code, notes, and snippets.

View AbraaoAlves's full-sized avatar
☀️
stay positive

AbraaoAlves AbraaoAlves

☀️
stay positive
View GitHub Profile
@AbraaoAlves
AbraaoAlves / tryGet.js
Created September 13, 2016 04:16
Ruby try function in Javascript today
Object.prototype.tryGet = function(props){
return (props || '').split('.').reduce( (a, b, i, l) =>
(a[b] || (i+1 === l.length ? '': {})
, this)
}
@AshleyGrant
AshleyGrant / app.html
Created July 19, 2016 19:06
Aurelia bug with checked.bind
<template>
<ul>
<li repeat.for="item of items">
<input
type="radio"
name="item"
value.bind="item"
checked.bind="selected">
${selected == item}
</li>
this.$rootScope.$on('f7:pageBeforeInit', (e, data) => {
const pageData = data.detail.pageData;
this.$F7Router.findRouteByUrl(pageData.url)
.then((route) => {
const config = route.config;
const navbar = data.detail.pageData.navbarInnerContainer;
const $scope = this.$rootScope.$new();
this.$controller(config.controller, {$scope}, null, config.controllerAs);
this.$timeout(() => {
var template = angular.element(pageData.container);
@nathanboktae
nathanboktae / ko-es5.js
Last active October 13, 2015 23:47
Knockout observables with ECMAScript 5 Properties - now at https://github.com/nathanboktae/knockout-es5-option4
(function(factory, global) {
if (global.define && global.define.amd) {
global.define(['ko'], factory);
} else {
factory(global.ko);
}
})(function(ko) {
var deepObservifyArray = function(arr, deep) {
for (var i = 0, len = arr.length; i < len; i++) {
@jimmyp
jimmyp / gist:4147580
Created November 26, 2012 10:35
TypeScript talk for ALT. NET
@puffnfresh
puffnfresh / covariant.ts
Created October 1, 2012 17:06
Covariant arrays. Blurgh.
// Compiles fine even though the code is broken.
// This is because arrays are covariant and mutable.
//
// TypeScript team: Please fix either of those things. Preferably mutability :)
class Animal {}
class Snake extends Animal {
slither() {
alert("Slithering!")
@alisterlf
alisterlf / gist:3490957
Created August 27, 2012 18:10
JAVASCRIPT:Remove Accents
function RemoveAccents(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else
@AbraaoAlves
AbraaoAlves / labelFadeInput
Created September 24, 2011 21:00
labelFadeInput is a plugin to show/hide message in input:text with title attribute. Message is set tough of title attribute
//demo: http://jsfiddle.net/uPvTm/8/
;(function($) {
$.labelFadeInput = function () {
///use to set labelFadeInput in All input's with title
///ex: <input type='text' title='Any text here' />, use $.labelFadeinput();
$('input:text[title]').each(function() {
setEvents.call(this);
});
@AbraaoAlves
AbraaoAlves / loadOptions and clearOptions
Created May 16, 2011 20:08
Method to insert options in select tag from json object.[update performance]
///<summary> Sample: </summary>
///<code>
/// $.getJson("url", function(data){
/// //data : [{Value:1, Text: 'value 1', Selected:false},{Value:2, Text: 'value 2', Selected: true}]
/// $("#mySelect").loadOptions(data);
/// });
/// or
/// $.getJson("url", function(data){
/// //data : [{id:1, name: 'value 1'},{id:2, name: 'value 2'}]
/// $("#mySelect").loadOptions(data, {value: 'id', text: 'name'});