Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View keenahn's full-sized avatar
🧙

Keenahn Tiberius Jung keenahn

🧙
View GitHub Profile
@keenahn
keenahn / git-default-branch.sh
Last active November 16, 2023 10:21
A simple bash script to check if the default branch is main or master for a given repo
#!/bin/bash
# Check if the remote 'origin' has a 'main' branch
if git show-branch remotes/origin/main > /dev/null 2>&1; then
echo "main"
else
echo "master"
fi
@keenahn
keenahn / 1-main.css
Last active January 24, 2019 18:10
Dark Asana Style with Less Elements
/* Dark theme */
/* Source Sans Pro,Lato,apple-system, */
.CustomPropertyHeader-fieldHeading--highlighted .CustomPropertyHeader-fieldName {
color: #fff;
}
.TeamOverview-inner, .TeamOverview-scrollable {
background: #222;
}
@keenahn
keenahn / colortrans.py
Created May 4, 2017 02:43 — forked from MicahElliott/colortrans.py
Convert values between RGB hex codes and xterm-256 color codes.
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code
#
# At CoverHound, we use conditional validations all over the form. However, there is no proper way to do
# this in Rails. Instead, we can provide an array of attributes (validated_fields attribute)
# and ensure they are the only ones to get validated.
#
module ConditionalValidations
attr_accessor :validated_fields
def field_is_required?(field)
@keenahn
keenahn / file-upload-validation.js.coffee
Created December 3, 2012 21:29
JS: File upload validation
# Just some examples of how to do file validation with javascript
# IS NOT BULLETPROOF and should be coupled with server side validation
# But, it can help
validate_file = ->
file = @fileInput.files[0]
if "name" of file
name = file.name
else
name = file.fileName
if "size" of file
@keenahn
keenahn / gist:3412140
Created August 21, 2012 05:30
BASH: grep current and subdirectories, only including rails files
grr(){
grep -iRn "$*" --include=*.{rb,erb,haml,html,css,scss,sass,json,js,coffee} .
}
# Put this in your .bashrc or equivalent
# then use like this:
# $ grr stuff
@keenahn
keenahn / image.rb
Created August 16, 2012 23:45
Ruby: Nicedit + Carrierwave for image uploads
class Image < ActiveRecord::Base
attr_accessible :f
mount_uploader :f, ImageUploader
end
@keenahn
keenahn / to_slug.js.coffee
Created July 26, 2012 20:12
String to Slug (coffeescript)
to_slug = (str) ->
str = str.replace(/^\s+|\s+$/g, "").toLowerCase() # trim and force lowercase
from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"
to = "aaaaeeeeiiiioooouuuunc------"
for i in [i..from.length]
str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i))
# remove accents, swap ñ for n, etc
str = str.replace(/[^a-z0-9 -]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-")
# remove invalid chars, collapse whitespace and replace by -, collapse dashes
return str # unnecessary line, but for clarity
@keenahn
keenahn / youtube_iframe.js.coffee
Created July 18, 2012 22:30
Create a youtube iframe using jQuery
jQuery ->
window.youtube_iframe = (video_id, args) ->
default_options = {
width: 853
height: 480
autoplay: 0
rel: 0
class: "youtube-video"
frameborder: "0"
allowfullscreen: true
@keenahn
keenahn / wgets.sh
Created July 8, 2012 06:56
wget a list of files
#!/bin/bash
while read line
do
echo $line
wget $line > /dev/null 2>&1
done < $1
# USAGE: wgets.sh a.txt
# Where a.txt is a list of URLs
# Pretttty simple. TODO: accept redirected input as well