Skip to content

Instantly share code, notes, and snippets.

View dvidsilva's full-sized avatar
❤️
Enamorao

Daveed Silva dvidsilva

❤️
Enamorao
View GitHub Profile
<!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>
(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);
})();
@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'),
);
}
@dvidsilva
dvidsilva / table
Created July 13, 2013 18:42
creates a table using an array
public function table($array,$headers,$title){
$table = '';
$table .= "<table id=table class=table >\n";
if($title != ''){
$table .= "<caption >$title</caption>\n";
}
$table .=" <thead><tr>\n";
$r = 1;
if(!is_array($headers)){
$headers = array_keys($array[0]);
var total = 0;
var suma = 0;
$.each($("input"), function (index, value) {
total = total + 1 ;
if( $(value).val() != '' ){
suma = suma + 1 ;
}
});