Skip to content

Instantly share code, notes, and snippets.

View keolo's full-sized avatar

keolo

View GitHub Profile
@keolo
keolo / designer.html
Last active August 29, 2015 14:06
designer
<link rel="import" href="../ace-element/ace-element.html">
<link rel="import" href="../chart-js/chart-js.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@keolo
keolo / gist:3277251
Created August 6, 2012 18:10
Acorn hover
// 1. Create a square container for the transparent Acorn image
// 2. Imagine we split the sqaure container diagonally to create an upper and lower triangle
// 3. Determine if the mouse is in the upper triangle of the container with the following formula:
//
// position = containerHeight * x + containerWidth * y - containerWidth * containerHeight
$context = $('.image-card');
// Calculate which triangle (half of square) we're in
$('a.image-link', $context).live('mousemove', function(e) {
@keolo
keolo / gist:3099788
Created July 12, 2012 18:08
Virtual Machines

Sometimes when copying a virtual machine on ubutntu it will also copy persistent config that matches on mac address. You can remove all of the rules in this file and reboot the machine.

sudo vi /etc/udev/rules.d/70-persistent-net.rules

sudo reboot now

@keolo
keolo / gist:2287026
Created April 2, 2012 20:31
Git cheat sheet

Show commits and diffs where foo_bar was introduced or removed from the code

git log --oneline -S'foo_bar' -p

Get list of modified files between two changesets

git diff --name-status <SHA1> <SHA2>

git show --name-only

@keolo
keolo / gist:2175024
Created March 23, 2012 21:00
Fake Gem

Trick bundler into thinking a gem is installed

This was useful for me when I wanted to use capybara-webkit on my linux machine but not on my os x machine.

gem install fake-gem

gem fake --version 0.9.0 capybara-webkit

@keolo
keolo / gist:1603923
Created January 13, 2012 00:03
webdriver
# gem 'selenium-webdriver'
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
driver.get "http://google.com"
element = driver.find_element :name => "q"
element.send_keys "Cheese!"

nc (netcat) example usage

nc localhost 8012
GET /s?q=box HTTP/1.1
Host: example.com
User-Agent: Listing Sync

Referrer: mypage.com

@keolo
keolo / ie_vm.md
Created November 8, 2011 01:32
IE Browser Testing
  1. Goto https://www.microsoft.com/download/en/details.aspx?id=11575 and download the Windows_XP_IE6.exe file

  2. This exe file is actually a RAR wrapper, so add a .rar extension and use a program like Keka to extract it. (You should end up with a “Windows XP.vhd” file)

  3. Also download the iso from https://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/ (my version was 0.1-15)

  4. Start VirtualBox and create a new VM. (I give it 512MB ram). Give it a new hard disk (choose VDI, dynamic, 64GB). Do NOT use the existing VHD you downloaded, it won’t work! Navigate to the new VM directory in Finder and copy the Windows XP.vhd there.

  5. Rename "Windows Xp.vhd" to xp.vhd.

# app/assets/javascripts/application.js
//= require_tree .
# app/assets/javascripts/application.js.coffee
@application =
awesomeFunction: (params) ->
console.log(params)
# app/assets/javascripts/home.js.coffee
$ ->
# There's got to be a better way to do this!!
class Object
def instance_values
self.instance_variables.map{|var| var_sym = var.to_s.gsub('@','').to_sym; {var_sym => self.send(var_sym)}}
end
end