Skip to content

Instantly share code, notes, and snippets.

View visoft's full-sized avatar

Damien White visoft

View GitHub Profile
@visoft
visoft / Ember-Delete-Button-Component.markdown
Created June 19, 2014 22:18
Ember Delete Button Component

Ember Delete Button Component

Using Zurb Foundation and Font Awesome, I came up with a delete button that changes to a confirmation button. If you confirm, the delete goes through, otherwise if you move your mouse off the button, it resets back to just a normal delete button.

A Pen by Damien White on CodePen.

License.

@rwilcox
rwilcox / keymando.rb
Created August 9, 2011 12:25
Useful motion commands for Keymando (also, example of command, delete)
# Motion commands
map "<Alt-Delete>", "<Alt-Right><Alt-Delete>" # Delete entire current word
map "<Cmd-Alt-Delete>", "<Cmd-Right><Cmd-Delete>" # Delete entire current line
# Move the current line one line up, or one line down (switch this line with the line currently
# above or below it)
#
# See also: TextMate's Text -> Move Selection -> Line Up (or Line Down)
map "<Cmd-Ctrl-Up>", "<Cmd-Left><Shift-Cmd-Right><Cmd-x><Delete><Up><Return><Shift-Cmd-Left><Delete><Cmd-v>"
map "<Cmd-Ctrl-Down>", "<Cmd-Left><Shift-Cmd-Right><Cmd-x><Delete><Down><Cmd-Right><Return><Shift-Cmd-Left><Delete><Cmd-v>"
@bouchard
bouchard / gist:1528761
Created December 28, 2011 17:18
Force Lowercase and Force Parameterize for Acts as Taggable On.
module ActsAsTaggableOn
class TagList < Array
cattr_accessor :force_lowercase, :force_parameterize
self.force_lowercase = false
self.force_parameterize = false
private
# Remove whitespace, duplicates, and blanks.
def clean!
@stakes
stakes / attribute_serializer.rb
Created February 24, 2011 20:11
Attribute Serializer with dynamic finders
module AttributeSerializer
module ActiveRecordExtensions
module ClassMethods
def serializeable(serialized, serialized_accessors={})
serialize serialized, serialized_accessors.class
serialized_attr_accessor serialized, serialized_accessors
@flarik
flarik / dot.powrc.sh
Created June 12, 2013 10:25
Pow's .porwrc config file for use with RVM's config files .rvmrc or .ruby-version (+ optional .ruby-gemset)
if [ -f "${rvm_path}/scripts/rvm" ]; then
source "${rvm_path}/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
elif [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then
rvm use `cat .ruby-version`@`cat .ruby-gemset`
elif [ -f ".ruby-version" ]; then
rvm use `cat .ruby-version`
@lexrus
lexrus / asicon.sh
Created March 6, 2012 08:48
AppStore Icons Generator
#!/bin/bash
# According to https://developer.apple.com/library/ios/#qa/qa1686/_index.html
# Install ImageMagick with MacPort: sudo port install ImageMagick
convert $1 -resize 512x512 iTunesArtwork.png # Ad Hoc iTunes
convert $1 -resize 144x144 Icon-72@2x.png # Home screen for "The New iPad"
convert $1 -resize 114x114 Icon@2x.png # Home screen for Retina display iPhone/iPod
convert $1 -resize 72x72 Icon-72.png # App Store and Home screen on iPad
convert $1 -resize 58x58 Icon-Small@2x.png # Spotlight and Settings for Retina display
convert $1 -resize 57x57 Icon.png # Home screen on non-Retina iPhone/iPod
convert $1 -resize 50x50 Icon-Small-50.png # Spotlight on iPad 1/2
@chrisgaunt
chrisgaunt / rails_test_engine_cucumber.markdown
Created August 3, 2011 03:57
Rails 3.1: Test engine with Cucumber & test/dummy app

Run from the root of the engine project:

rails generate cucumber:install --capybara

Edit features/support/env.rb and add to the top:

ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../../test/dummy/config/environment.rb",  __FILE__)
ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "../../../test/dummy"
@pgaertig
pgaertig / transpose_table.js
Created April 13, 2012 13:48
Transpose HTML table using jQuery
$(function() {
var t = $('#thetable tbody').eq(0);
var r = t.find('tr');
var cols= r.length;
var rows= r.eq(0).find('td').length;
var cell, next, tem, i = 0;
var tb= $('<tbody></tbody>');
while(i<rows){
cell= 0;
// Clamps a block of text to a certain number of lines,
// followed by an ellipsis in Webkit and Blink based browsers
// Reference: http://dropshado.ws/post/1015351370/webkit-line-clamp
@mixin text-clamp($lines: 2, $line-height: false) {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: $lines;
// Fallback for non-Webkit browsers
import { useState, useEffect, useCallback } from "react";
interface RequestProps<T> {
url: RequestInfo;
init?: RequestInit;
processData?: (data: any) => T;
}
export const useFetch = <T>({ url, init, processData }: RequestProps<T>) => {
// Response state