Skip to content

Instantly share code, notes, and snippets.

View ksaynice's full-sized avatar

-=K=- ksaynice

View GitHub Profile
@ksaynice
ksaynice / weather.rb
Last active October 5, 2015 09:07
Weather via ruby
#!/usr/bin/env ruby -wKU
#
require 'rexml/document'
xml = `curl -s "http://www.google.com/ig/api?weather=94030"`
doc = REXML::Document.new(xml)
condition = doc.root.elements["weather/current_conditions/condition"].attributes['data']
wind_condition = doc.root.elements["weather/current_conditions/wind_condition"].attributes['data']
wind_condition = wind_condition.match(/\d+/).to_s
temp_f = doc.root.elements["weather/current_conditions/temp_f"].attributes['data']
{
/* Remap Home / End keys to be correct ~/Library/KeyBindings*/
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
@ksaynice
ksaynice / 3d_book_cover.css
Created October 18, 2013 17:26
3D CSS Book Covers
/* Fallback styles */
.book {
display: inline-block;
box-shadow: 5px 5px 20px #333;
margin: 10px;
}
.book img { vertical-align: middle; }
/*
def merge_sort(arr)
return arr if arr.size <= 1
left, right = halve_array(arr)
left_part = merge_sort(left)
right_part = merge_sort(right)
array = []
offset_left_part = 0
offset_right_part = 0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.811765 0.796078 0.564706 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 16.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@ksaynice
ksaynice / ksaynice.pp
Created August 14, 2014 22:26
K's Boxen personal module
class people::ksaynice {
# ----- First thing first make you chooice of editor(s)! -----
include textmate::textmate2::release # normal release
# include textmate::textmate2::beta # beta releases
# include textmate::textmate2::nightly # nightly releases
# # sublime_text For the latest build of v3
# include sublime_text
# sublime_text::package { 'Emmet':
@ksaynice
ksaynice / access_code_generator.rb
Last active August 29, 2015 14:06
Random generate access code
class AccessCodeGenerator
def self.generate(size = 13)
charset = ([*('A'..'Z'),*('0'..'9')]-%w(0 1 5 8 B I L O S U))
(0...size).map{ charset.to_a[SecureRandom.random_number(charset.size)] }.join
end
end
@ksaynice
ksaynice / gist:208828d7ea889edcdd88
Last active December 4, 2017 09:07 — forked from bkimble/gist:1365005
List all keys stored in memcache
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
# Function to print strftime results
def print_strftime_formats(a,cur_date)
a.each do |format|
b = "%#{format}"
output = cur_date.strftime(b)
puts "t.strftime('#{b}'), => #{output}"
end
end
a = ('a'..'z').to_a
class ProcessImage
class ResizeCover < ProcessImage::Base
include Interactor
include MomCatalogModels::Fileable
GRID_W = 960
GRID_H = 1200
def call
magic_resize_cover