Skip to content

Instantly share code, notes, and snippets.

View dvidsilva's full-sized avatar
❤️
Enamorao

Daveed Silva dvidsilva

❤️
Enamorao
View GitHub Profile
@dvidsilva
dvidsilva / List of common typos
Created February 16, 2014 22:06
# This file contains a number of common English typos: andriod->android
# The remainder of this file contains misspellings from
# http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
# plus some post-processing to fix invalid entries, remove duplicates, etc.
#
# The content is available under the
# "Creative Commons Attribution-ShareAlike License"
# http://creativecommons.org/licenses/by-sa/3.0/
abandonned->abandoned
@dvidsilva
dvidsilva / LoadYoutubeVideo
Created January 22, 2014 22:23
Something bla bla bla bla
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
(function(){
var script=document.createElement('script');
script.setAttribute('src','http://cssrefresh.frebsite.nl/js/cssrefresh.js');
var head=document.getElementsByTagName('head');
head[0].appendChild(script);
})();
<!doctype html>
<html lang='en-US'>
<head>
<title >This is a website</title>
<meta charset='utf-8'>
<link rel='shortcut icon' href='favicon.ico' />
<meta http-equiv='cleartype' content='on'>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='app.css' />
</head>
@dvidsilva
dvidsilva / gist:8130777
Last active January 1, 2016 10:19
Hide the onion prompt to sign in after you saw 30 articles in a month
$('#gregbox-outer').hide();
$('#gregbox-signInTab').hide();
$('#gregbox-outer').siblings('div')[2].style.display = 'none';
@dvidsilva
dvidsilva / Google analytics in coffescript
Created October 15, 2013 22:30
I'm using chaplin and brunch, in coffeescript, bit of a mess, this is how we implemented the google analytics tracking code the following was put in the app/base/controller.coffe in beforeAction: (params, route) ->
((i, s, o, g, r, a, m) ->
i["GoogleAnalyticsObject"] = r
i[r] = i[r] or ->
(i[r].q = i[r].q or []).push arguments
i[r].l = 1 * new Date()
a = s.createElement(o)
m = s.getElementsByTagName(o)[0]
@dvidsilva
dvidsilva / Patterns in string
Last active December 25, 2015 13:59
Find the places where certain pattern occur in a string using JS, keeping in mind interpolation and not repeating the result. Is using node :P
var start = new Date().getTime();
var str="";
var mtc="CTTGATCAT";
var n = " ";
var alr = new Array();
var j = 0;
var url = 'https://beta.stepic.org/media/attachments/lessons/3/Vibrio_cholerae.txt';
var http = require('https');
var fs = require('fs');
@dvidsilva
dvidsilva / the best js file there is in the universe
Created September 26, 2013 07:40
Get all background images in a page and create a canvas/sprite with them, with plain js
document.getElementsByTagName("body")[0].innerHTML += '<canvas id=sprite ></canvas>';
var items = document.getElementsByTagName("*");
var c = document.getElementById("sprite");
c.width = 4000;
c.height = 10000;
c.style.border = '1px solid black';
var y = 0;
var x = 0;
@dvidsilva
dvidsilva / jquery insert
Created September 4, 2013 04:37
Programmatically add jquery to a page
var head = document.getElementsByTagName("head");
var node = document.createElement("script");
node.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js";
head[0].appendChild(node);
<?php
public function rules()
{
return array(
array('roleid', 'verificarCodigo'),
);
}