Skip to content

Instantly share code, notes, and snippets.

@ziadoz
ziadoz / meta-programming.php
Created July 17, 2012 03:35
Basic Meta Programming with PHP 5.4
<?php
trait MetaClass
{
protected $__classMethods = array();
static protected $__staticMethods = array();
public function __call($name, $args)
{
@andrekandore
andrekandore / gist:3140554
Created July 19, 2012 03:27 — forked from RiANOl/gist:1077760
AES128, AES256 encrypt/decrypt in Ruby
require "openssl"
require "digest"
def aes128_encrypt(key, data)
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize)
aes = OpenSSL::Cipher.new('AES-128-CBC')
aes.encrypt
aes.key = key
aes.update(data) + aes.final
end
@ttscoff
ttscoff / planter.rb
Created September 22, 2012 17:57
Create directory trees from indented text input
#!/usr/bin/ruby
=begin
Planter v1.3
Brett Terpstra 2013
ruby script to create a directory structure from indented data.
Three ways to use it:
- Pipe indented (tabs or 2 spaces) text to the script
- e.g. `cat "mytemplate" | planter.rb
- Create template.tpl files in ~/.planter and call them by their base name
@banago
banago / get-fisrt-paragraph.php
Created November 6, 2012 09:18
Get first paragraph from a WordPress post.
<?php
/**
* Get first paragraph from a WordPress post. Use inside the Loop.
*
* @return string
*/
function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );
@chrisvanpatten
chrisvanpatten / _fonts.scss
Last active December 10, 2015 17:39
Fonts
/*
* Using Sass's @each loop to automatically generate code for web fonts
*/
$fonts: (vpm, font-awesome);
@each $font in $fonts {
@include font-face( $font,
font-files(
'#{$font}/#{$font}.woff',
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@darren131
darren131 / config.rb
Created April 17, 2013 05:58
Compass and Wordpress Automating folder name and theme name Note in style.scss comment section we call wp_theme_name()
# get the name of your theme folder
WP_THEME_FOLDER = File.basename(File.dirname(__FILE__))
# best path for assets in Wordpress project
http_path = "/wp-content/themes/#{WP_THEME_FOLDER}/"
css_dir = "."
sass_dir = "sass"
images_dir = "img"
javascripts_dir = "js"
fonts_dir = "fonts"
@dabit
dabit / hash_table.rb
Last active May 16, 2023 16:57
Code example for my blogpost Hash lookup in Ruby, why is it so fast?
require 'benchmark'
#
# Code example for my blogpost
#
# Hash lookup in Ruby, why is it so fast?
#
#
# Struct used to store Hash Entries
@chriseppstein
chriseppstein / captures.scss
Last active May 7, 2018 18:09
I had this idea for how to expose general stylesheet structure data to SassScript, transform it, and then turn it back into styles.
// A named buffer. Will append to existing content captured there.
// The buffer can be accessed via get-capture("foo") or @emit "foo".
@capture "foo" {
@media screen {
.asdf {
.qwerty {
/* This is a comment */
color: red;
}
}
@livibetter
livibetter / README.md
Last active August 17, 2019 16:34
Let It Rain!