Skip to content

Instantly share code, notes, and snippets.

View AlainPilon's full-sized avatar

Alain Pilon AlainPilon

  • Montreal, Canada
View GitHub Profile
@AlainPilon
AlainPilon / phantom.py
Last active January 5, 2018 16:14 — forked from jsok/phantom.py
Use PhantomJS and Python Selenium bindings to take screenshots of websites.
from io import BytesIO
from selenium import webdriver
from PIL import Image
driver = webdriver.PhantomJS()
driver.set_window_size(1366, 728) # optional
driver.get('http://google.com')
driver.save_screenshot('screen_hires.png')
def proxied_format
(kind == 'rss' || twitter? || weather_canada?) ? ".xml" : ".json"
end
@AlainPilon
AlainPilon / tmux.md
Last active August 29, 2015 14:11 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script src="jquery.expander.js"></script>
<script>
$(function() {
$('.long-description').expander({userCollapseText: '&and; view less &and;',
@AlainPilon
AlainPilon / gist:1418826
Created December 1, 2011 18:34
expander bug #does not show the 'continue reading'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script src="jquery.expander.js"></script>
<script>
$(function() {
$('.long-description').expander({userCollapseText: '&and; view less &and;',
class Visit < ActiveRecord::Base
before_validation {|record| record.visited_on = 'test'}
end
a = Visit.first
a.visited_on
=> nil
a.user_id
=> 1
a.user_id = 5