Skip to content

Instantly share code, notes, and snippets.

$data = $YOUR_QR_STUFF->getImage();
ob_start();
imagepng($data);
$image_data = ob_get_contents();
ob_end_clean();
store_stuff_in_redis($key, $data);
@cviebrock
cviebrock / select2-foundation5.css
Created December 20, 2013 15:56
Select2 CSS for Zurb Foundation 5
/*
Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
*/
.select2-container {
margin: 0 0 1rem 0;
position: relative;
vertical-align: middle;
font-family: inherit;
-webkit-appearance: none !important;
font-size: 0.875rem;

index.html:

<html lang="en">
	<head>
	</head>
	<body>
		...
		<script data-main="/js/config" src="/js/lib/require.min.js"></script>
 
@cviebrock
cviebrock / gist:6598105
Created September 17, 2013 18:00
Convert `"/Date()/"` dates from JSON to DateTime objects.
function convertJsonDate( $string ) {
if ( preg_match('#^/Date\((-?\d+)([+-]\d+)?\)/$#', $string, $matches) ) {
$ds = intval( $matches[1] ) / 1000;
$dm = intval( $matches[1] ) % 1000;
$tz = '+000';
if ( isset($matches[2]) ) {
$tz = $matches[2];
}
@cviebrock
cviebrock / github_issues_to_csv_v3.rb
Created October 12, 2012 17:19
Export Github Issues to CSV (OSX 10.7.5 version)
require 'rubygems'
require 'octokit'
require 'fastercsv'
require 'date'
# Description:
# Exports Github issues from one or more repos into CSV file formatted for import into JIRA
# Note: By default, all Github comments will be assigned to the JIRA admin, appended with
# a note indicating the Github user who added the comment (since you may not have JIRA users
# created for all your Github users, especially if it is a public/open-source project:
@cviebrock
cviebrock / DateFormat.php
Created March 14, 2012 21:50
DateFormat class for Laravel (or anyone)
<?php
class DateFormat {
const DATE_SHORT = 'Y-m-d';
const DATE_LONG = 'F j, Y';
const DATETIME_SHORT = 'Y-m-d H:i';
const DATETIME_LONG = 'F j, Y, g:i a';
@cviebrock
cviebrock / gist:2029682
Created March 13, 2012 16:16
Laravel database init task?
<?php
/**
* /application/tasks/db.php
*/
class DB_Task {
/**
* php artisan db:init [connection] [user]
@cviebrock
cviebrock / gist:2007340
Created March 9, 2012 16:21
Data Factory
<?php
class Data {
public static function factory()
{
$args = func_get_args();
if (count($args)==0) {
<?php
// $rules = array(
// 'field' => 'required|date:Y-m-d'
// );
public function validate_date($attribute, $value, $parameters)
{
$format = $parameters[0];
@cviebrock
cviebrock / gist:1996758
Created March 7, 2012 22:31
serializable abstract eloquent class :)
<?php
class Data extends Aware {
public static $timestamps = true;
public static $table = 'data';
private static $class = null;