Skip to content

Instantly share code, notes, and snippets.

View coatezy's full-sized avatar
🏍️

Tom Coates coatezy

🏍️
View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=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')
<?php # -*- coding: utf-8 -*-
/**
* Create a nav menu with very basic markup.
*
* @author Thomas Scholz http://toscho.de
* @version 1.0
*/
class T5_Nav_Menu_Walker_Simple extends Walker_Nav_Menu
{
/**
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@mm53bar
mm53bar / README.md
Last active December 11, 2015 05:28 — forked from mynameisrufus/db_backup.sh
Stop using Ruby to back up the postgres database in your Rails app. Use bash instead!

Backing up Postgres with Bash

Stop using Ruby to back up the postgres database in your Rails app. Use bash instead!

##Install:

cd /usr/local/bin
git clone https://gist.github.com/4552332.git db_backup

chmod +x db_backup/db_backup.sh

Devise / Warden Tagged logging

I wrote a middleware (actually two, but they do the same with different implementations) that logs information about signed in scopes in a Rails + Devise application. The solution works with multiple logins (like having a person logged both as an Admin and a User). I tested against Rails 4 and Devise HEAD, but it should work fine in any Rails 3 application.

This solution doesn't use the log_tags configuration option since it isn't very helpful when you need to retrieve information stored in cookies/session. That information isn't 'ready' when the Rails::Rack::Logger is executed, since it happens way down in the middleware chain.

Add one of the following implementations to your application load path and use the following configuration to add the middleware to your application stack:

# application.rb
@willurd
willurd / web-servers.md
Last active July 12, 2024 11:21
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@farmdawgnation
farmdawgnation / date-dot-parse.js
Last active August 29, 2015 13:56
A Date.parse implementation from Stackoverflow stuffs.
// This is a slightly modified version of two patches. The first suggested at
// http://stackoverflow.com/questions/5802461/javascript-which-browsers-support-parsing-of-iso-8601-date-string-with-date-par
// and the second, for Date.js suggested at
// http://stackoverflow.com/questions/12145437/date-js-parsing-an-iso-8601-utc-date-incorrectly
//
// Here we override the implementation of Date.parse provided by Date.js. In this implementation we
// first check to see if we can construct the date using the Date constructor. If we can, we move
// along. If we cannot, we attempt to start the Date.js grammar parser. If that, too, fails us, we
// then assume we're running in IE 8, and someone passed in an ISO8601 string, which IE8's date
// constructor won't recognize. So we try to manually parse it out, returning a Date instance.
@probonopd
probonopd / F1E200.md
Last active June 30, 2024 18:12
Allwinner F1E200 electronic postcard with USB Device ID 1f3a:1000

USB Device ID 1f3a:1000 Allwinner F1E200 electronic postcard

I received a promotional folder that plays a video with sound when opening the folder. This contains a rechargeable LiPo battery, a TFT display, a speaker, a power switch, a push button, 256 MB flash memory, RAM, and a CPU.

All of this for watching one 1-minute video.

What a waste! Certainly not environmentally friedndly. Until repurposed creatively!

On the back it says that the product can be sent back to the manufacturer for free recycling. Still I was wondering if I could do more with it.

@dadoonet
dadoonet / search_kibana_console.txt
Last active July 4, 2024 09:28
Demo script for "A NoSQL search engine to find..." talk
### REINIT
DELETE user
PUT user
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"comments": {