Skip to content

Instantly share code, notes, and snippets.

View dvidsilva's full-sized avatar
❤️
Enamorao

Daveed Silva dvidsilva

❤️
Enamorao
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dvidsilva on github.
  • I am dvidsilva (https://keybase.io/dvidsilva) on keybase.
  • I have a public key whose fingerprint is 4408 194C 5E0E DC7E ED83 830B ECF6 B6A9 5D87 FD19

To claim this, I am signing this object:

@dvidsilva
dvidsilva / Check for mobile
Created August 11, 2014 06:14
check the user agent to see if the browser is ios or android and add a class to the body
function isAppleDevice(){
return (
(navigator.userAgent.toLowerCase().indexOf("ipad") > -1) ||
(navigator.userAgent.toLowerCase().indexOf("iphone") > -1) ||
(navigator.userAgent.toLowerCase().indexOf("ipod") > -1)
);
}
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android");
var appStoreURL = "";
@dvidsilva
dvidsilva / Bubblesort
Last active August 29, 2015 14:02
Bubble sort in JS
var a = [199, 123, 23, 1241, 2412, 123 ,44, 5, 23, 1, 13];
function sortWithBubble(arr)
{
var swapped;
do {
swapped = false;
for (var i=0; i < arr.length-1; i++) {
if (arr[i] > arr[i+1]) {
var temp = arr[i];
@dvidsilva
dvidsilva / Markdown Reference
Created May 29, 2014 08:35
Short reference and introduction to markdown. Taken and expanded from https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
This is intended as a quick reference and showcase. For more complete info, see [John Gruber's original spec](http://daringfireball.net/projects/markdown/).
PLEASE DO NOT EDIT THIS PAGE! You can play around with Markdown on our [live demo page](http://www.markdown-here.com/livedemo.html).
##### Table of Contents
[Headers](#headers)
[Emphasis](#emphasis)
[Lists](#lists)
[Links](#links)
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 200 ]; do
curl "https://connectapi.telescope.tv/vote?apiKey=nascallstar2014&deviceType=web&timestamp=1397365183350&action_type=vote&country=US&state=CA&doubleVote=false&sprintCustomer=O&insiderEmailOptin=true&smsOptin=false&emailOptin=true&email=none"%"40dispostable.com&v=A12" -H "Origin: http://e1.votenow.tv" -H "Accept-Encoding: gzip,deflate,sdch" -H "Accept-Language: es,en-US;q=0.8,en;q=0.6,he;q=0.4" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Referer: http://e1.votenow.tv/?app=web&ref=http"%"3A"%"2F"%"2Fwww.nascar.com"%"2FSprintFanVote.html" -H "Connection: keep-alive" --data "Authorization=kZVndoQjJx8hs0lj8lf6dW2rKEM"%"3D" --compressed
echo the counter is $COUNTER
let COUNTER=COUNTER+1
sleep 1
done
Hey shibes! you might know by now but there was a terrible fire in Chile, that killed some people and destroyed many houses in an area that was already in not great shape.
http://www.usatoday.com/story/news/world/2014/04/13/forest-fire-chile-homes/7664531/
We've been working a lot in Josh and letting the word out, but we're all about helping others and this is some people that need it.
I'm getting in touch with [Techo](http://www.techo.org/en/) they have the most experience in the country helping in these situations to find a way to send them money from here.
Any cent helps :) in this cases people can benefit from even the cheapest things, since water sources are hard to get to, diapers for kids, etc.
@dvidsilva
dvidsilva / .vimrc.bundles.local
Created March 26, 2014 00:00
I use https://github.com/square/maximum-awesome for my vim basic config, this two extra files are the local shorcuts and plugins that i add.
Bundle 'chriskempson/tomorrow-theme', {'rtp': 'vim/'}
Bundle "xolox/vim-misc"
Bundle "xolox/vim-session"
Bundle "vim-multiple-cursors"
Bundle 'groenewege/vim-less'
Bundle 'kchmck/vim-coffee-script'
@dvidsilva
dvidsilva / inline js in yii view
Created March 24, 2014 17:57
example on how to add js in a view
//here view code, mostly HTML with php snippets to insert variables
//...
//...
//block with JS code
<?php
<?php
Yii::app()->clientScript->registerScript('settings-script', <<<EOD
FB.Event.subscribe('edge.create', function(response) {
alert('You liked the URL: ' + response);
@dvidsilva
dvidsilva / angular-google-map-directive
Created March 19, 2014 18:47
Angular directive to embed google maps in your application
#put the map url in a map attribute in the dom element that has this directive.
#it will get the location from the map url and create an iframe
myApp.directive 'gMap', ->
restrict: "EA"
link: (scope, element, attrs)->
if attrs.map
re = /@(-?\d+\.?\d*,-?\d+\.?\d*),([\d]{1,2})z/gi
url = ''
attrs.map.replace re, (match, lat, z)->
z = z || 10
{
"provider": "ddg",
"query": "cat pircures",
"type": "images",
"results": [
{
"title": "",
"description": "",
"media": {
"url": "gato.png",