Skip to content

Instantly share code, notes, and snippets.

View carwin's full-sized avatar
🍔
cheeseburger

Carwin Young carwin

🍔
cheeseburger
  • Missouri
View GitHub Profile
@carwin
carwin / ghfm.rb
Created March 27, 2013 11:28
GitHub Flavored Markdown Processor
#!/usr/bin/ruby
require 'rubygems'
require 'redcarpet'
require 'albino'
class SyntaxRenderer < Redcarpet::Render::HTML
def block_code(code, language)
if language && !language.empty?
Albino.colorize(code, language)
def convert(temp)
(temp.to_f - 32) * 5/9
end
puts "Give it to me in Fahrenheit:"
temp = gets
puts "Here it is in Celsius: " + convert(temp).to_s
@carwin
carwin / leap_year.rb
Last active December 20, 2015 22:49
Ruby method that tells you how many minutes are in a given year.
# encoding: utf-8
# Write a method leap_year?. It should accept a year value from the user, check
# whether it is a leap year and return true or false.
# Calculate and display the number of minutes in a leap year (2000 and 2004)
# and the minutes in a non-leap year (1900 and 2005).
MINUTES_IN_HOUR = 60
MINUTES_IN_DAY = MINUTES_IN_HOUR * 24
def leap_year?
puts "Give me a year, I'll tell you if it leaps:"
@carwin
carwin / SassMeister-input.scss
Created April 4, 2014 21:06
Generated by SassMeister.com.
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
@mixin some-color-name($color) {
@if type-of($color) == 'map' {
background-image: linear-gradient(map-get($color, key1), map-get($color, key2));
}
}
@carwin
carwin / element-background.scss
Created May 16, 2014 22:36
element background magic
@mixin element-background($color, $direction: top) {
@if type-of($color) == list {
background-color: nth($color, 1);
@include background-image(linear-gradient($direction, $color));
}
else {
@if ($color != 'none') {
$percent: alpha($color) * 100%;
$opaque: opacify($color, 1);
$solid-color: mix($opaque, white, $percent);
@carwin
carwin / your_module.module
Last active August 29, 2015 14:05
D7: Using the Picture module in code
<?php
/**
* Helper function.
*
* Prepares the necessary array for use with theme_picture.
*
* @param array $variables
* The image array loaded from field_get_items.
*
* @param string $group
@carwin
carwin / UpdateAndroidHosts
Created December 1, 2014 23:44
Update Android emulator hosts file
adb pull /system/etc/hosts /tmp/hosts
echo "192.168.57.1 test.example.com" >> /tmp/hosts
adb remount
adb push /tmp/hosts /system/etc
@carwin
carwin / SassMeister-input-HTML.html
Created February 12, 2016 03:16
Generated by SassMeister.com.
<div class="container">
<div class="A"><img src="http://placehold.it/1000x500" /></div>
<div class="B">
<div class="C"><img src="http://placehold.it/500x500" /></div>
<div class="D"><img src="http://placehold.it/500x500" /></div>
</div>
@carwin
carwin / ssb-interop.js
Created August 30, 2018 18:06
Theme Slack Desktop
// Append to the bottom of /usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js
document.addEventListener('DOMContentLoaded', function() {
$.ajax({
// Your CSS here.
url: 'https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css',
success: function(css) {
$("<style></style>").appendTo('head').html(css);
}
});
});
package dice
import {
"time"
"math/rand"
)
func RollDice(count int, sides int) int {
min := 1
max := sides