Skip to content

Instantly share code, notes, and snippets.

@Davidslv
Davidslv / browsers.js
Created February 3, 2014 08:14
jQuery bad code for browser detection
// Bad Code from Efytimes:
// http://efytimes.com/e1/fullnews.asp?edid=128774
// Please don't use this code in your website if you have jQuery > 1.9
$(document).ready(function() {
// If the browser type if Mozilla Firefox
if ($.browser.mozilla && $.browser.version >= "1.8" ){
// some code
}
// If the browser type is Opera
@Davidslv
Davidslv / fact.erl
Created February 5, 2014 20:11
Factorial function in erlang
-module(fact).
-export([factorial/1]).
%% The solution is tail recursive
factorial(N) ->
factorial(1, N, 1).
factorial(Current, N, Result) when Current =< N ->
NewResult = Result * Current,
@Davidslv
Davidslv / git-clean-branch.md
Last active August 29, 2015 13:57
Remove merged branches from local repo

If you want to do some housekeeping locally and want to remove branches that have been merged, checkout master and then:

git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
https://github.com/bbatsov/rubocop#atom
https://github.com/yujinakayama/atom-lint
https://github.com/AtomLinter/linter-rubocop
https://github.com/AtomLinter/Linter
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@Davidslv
Davidslv / super_service_object.rb
Last active August 29, 2015 14:13
how to speed up your workers?
class SuperServiceObject
attr_reader :user, :options
def new(user_id, options = {})
@user = User.find(user_id)
@options = options
end
def call
# move the code here
@Davidslv
Davidslv / timez.rb
Created April 29, 2015 14:32
Having fun with times
Failure/Error: expect(resource_time.to_time).to eq Time.now
expected: 2015-04-29 15:23:34 +0100
got: 2015-04-29 15:23:34 +0100
# Solution:
expect(resource_time.to_s).to eq Time.now.utc.to_s
@Davidslv
Davidslv / repeatme
Last active December 4, 2015 14:49
Bash function to repeat anything in the terminal
# usage: repeatme 3 "echo e"
function repeatme() {
for i in $(seq 1 $1) ; do
$2
done
}
@Davidslv
Davidslv / The Technical Interview Cheat Sheet.md
Created October 16, 2015 00:15 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
---
- "/government/statistics/announcements/deaths-registered-by-area-of-usual-residence-in-england-and-wales-monthly-provisional-july-2014"