- Use Control+W instead of Alt+Backspace
- To unindent a line, use Ctrl+D
- To indent a line, use Ctrl+T
- Upper-case J joins lines (same as Cmd+J in Sublime Text)
- Use :edit! to force a reload of the current file from disk.
- To skip to the first non-whitespace character on a line, press ^
- yy copies (yanks) a line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Time::DATE_FORMATS[:ymd] = "%F" # 2023-01-01 | |
Time::DATE_FORMATS[:mdy] = "%D" # 01/01/23 | |
Time::DATE_FORMATS[:human] = "%B %d, %Y" # January 01, 2023 | |
Time::DATE_FORMATS[:time_12] = "%I:%M %p" # 01:30 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to your scripts.yaml file | |
join_playing_sonos: | |
description: "Make a Sonos spaker join whichever speaker is current playing." | |
fields: | |
target: | |
description: "Entity ID of the Sonos which you'd like to make join the group" | |
example: "media_player.office" | |
variables: | |
group_owner: '{{ state_attr((integration_entities("sonos") | select("is_state", "playing") | first), "group_members") | first }}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merged () { | |
CURRENT=`git rev-parse --abbrev-ref HEAD`; | |
if git merge-base --is-ancestor $1 $CURRENT; then | |
echo "\e[32m$1 is merged into $CURRENT" | |
else | |
echo "\e[31m$1 is NOT merged into $CURRENT" | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build_package_combined_patch() { | |
local package_name="$1" | |
{ | |
curl https://github.com/ruby/ruby/pull/47.diff | git apply | |
curl https://gist.githubusercontent.com/zackfern/45914b53db7720146899/raw/cda389aaca50685f6f5f8496b0aa99b73dd4fa3b/performance_and_backport_gc.patch | patch -p1 | |
autoconf | |
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS | |
make -j 8 | |
make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Public: Parse values from Rails date_select form helper. | |
# | |
# dsv - Stands for Date Select Values. Pass in whatever hash | |
# contains the attributes of the date_select box. | |
# name - Name of the Date Select. For example, if your params | |
# contain 'date_of_birth(2i)' then your name would be | |
# 'date_of_birth' (which happens to be the default) | |
# | |
# Returns a Date object. | |
def parse_date_select_values(dsv, name='date_of_birth') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hacky last.fm Now Playing | |
// by Zack Fernandes (zackfern.me) April 2013 | |
// | |
// Instructions: | |
// - Install jQuery, if you don't have it already. | |
// - Create a last.fm API key and set the api_key variable. | |
// - Set the username variable to your last.fm username. | |
// - Add something with the ID of now_playing in your site. | |
// - Include this script and enjoy. | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
// Loading the latest profile JSON from Preserve. | |
$.getJSON('http://preserve.io/u/zackfern.json', function(data){ | |
var items = []; | |
// How many bookmarks are we going to display? | |
var limit = 4; | |
var bookmarks = 0; | |
$.each(data.user.bookmarks, function(key, bookmark){ | |
if(bookmarks > limit) { | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# README | |
# This is a simple script to upload files to Amazon S3. | |
# Configuration is provided below for your S3 credentials, bucket to upload to, path to upload to, and base URL. | |
# When the script is finished, it will output the base URL followed by the path and uploaded file name. | |
# The script can rename files if USE_ORIGINAL_FILE_NAME is set to false. | |
# By default, it will name the file based off the current date and time (for example, 2013-03-03-153427.png). | |
# | |
# Once you've configured the script, simply pass the script the path to your file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST "http://localhost:9200/dashboard/_search?pretty=true" -d ' | |
{ | |
"query" : { "match_all" : {} }, | |
"facets" : { | |
"tags" : { "terms" : {"field" : "tags", "size" : 10} } | |
} | |
} | |
' |
NewerOlder