Skip to content

Instantly share code, notes, and snippets.

Avatar

Sergio Diaz kisai

  • UNOSQUARE
  • Mexico
View GitHub Profile
@kisai
kisai / github-window-fit.css
Created Mar 3, 2019
CSS for stylus extension to make Github fit smaller windows
View github-window-fit.css
@-moz-document domain("githubusercontent.com"), domain("graphql-explorer.githubapp.com"), regexp("^https?://((blog|gist|guides|help|raw|resources|status|developer)\\.)?github\\.com/((?!generated_pages/preview).)*$") {
body {
min-width: auto !important;
}
.container {
transition: width 0.2s;
}
.container {
View sass_and_less_compared.markdown

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@kisai
kisai / hangman.hs
Created Oct 7, 2015 — forked from ToJans/hangman.hs
A haskell implementation of the hangman game
View hangman.hs
import Control.Monad (when)
import Data.Char (toLower)
import Data.List (transpose)
import System.Random (randomIO)
wordsPath :: FilePath
wordsPath = "words.txt"-- "/usr/share/dict/words"
data GameState = GameState
{ _wordToGuess :: String
@kisai
kisai / mac.bash
Created Aug 27, 2015
Remove annoying mac bouncing of icons
View mac.bash
defaults write com.apple.dock no-bouncing -bool TRUE
killall Dock
@kisai
kisai / hiccup-style.clj
Created Dec 9, 2014
Extend hiccup syntax for css style attribute
View hiccup-style.clj
;; taken from http://stackoverflow.com/questions/12679754/idiomatic-way-of-rendering-style-info-using-clojure-hiccup
(defn style [& info]
{:style (.trim (apply str (map #(let [[kwd val] %]
(str (name kwd) " " val "; "))
(apply hash-map info))))})
@kisai
kisai / singleton_method.rb
Created Sep 18, 2014
Define a singleton method for a ruby object
View singleton_method.rb
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
@kisai
kisai / convert_object_to_hash.rb
Created Sep 12, 2014
Convert object to hash in ruby
View convert_object_to_hash.rb
class Gift
def initialize
@name = "book"
@price = 15.95
end
end
gift = Gift.new
hash = {}
gift.instance_variables.each {|var| hash[var.to_s.delete("@")] = gift.instance_variable_get(var) }
View custom_bundler_config.sh
#source http://stackoverflow.com/questions/5167829/how-can-i-pass-a-parameter-for-gem-installation-when-i-run-bundle-install
bundle config build.pg --with-pg-config=/path/to/pg_config
View gen_rsa_key_from_modulus.rb
#source: http://skim.la/2012/01/16/rsa-public-key-interoperability-between-ruby-and-android/
require 'openssl'
require 'base64'
rsa = OpenSSL::PKey::RSA.new(2048)
modulus = rsa.n
exponent = rsa.e
oid = OpenSSL::ASN1::ObjectId.new("rsaEncryption")
alg_id = OpenSSL::ASN1::Sequence.new([oid, OpenSSL::ASN1::Null.new(nil)])