Skip to content

Instantly share code, notes, and snippets.

View king724's full-sized avatar

Kevin King king724

View GitHub Profile
@BHSPitMonkey
BHSPitMonkey / generate_code39_barcode.php
Created September 8, 2010 19:32
A PHP function that generates a Code 39 type barcode in pure HTML/CSS
// Prints out a Code 39 barcode in HTML/CSS
// $string should be a Code 39-compliant string to encode.
// Any characters not in the array below will be discarded.
function print_code39_barcode($string) {
$code39 = array(
'0'=>'NnNwWnWnN', '1'=>'WnNwNnNnW',
'2'=>'NnWwNnNnW', '3'=>'WnWwNnNnN',
'4'=>'NnNwWnNnW', '5'=>'WnNwWnNnN',
'6'=>'NnWwWnNnN', '7'=>'NnNwNnWnW',
'8'=>'WnNwNnWnN', '9'=>'NnWwNnWnN',
@jai-o
jai-o / htaccess-try97
Created April 5, 2012 18:47
Works! Removes Index.php, Force HTTPS, removes www
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1
# Depends on your web host and setup, check with your web host specific settings
RewriteCond %{ENV:SECURE_REDIRECT} !=on
@alexbilbie
alexbilbie / composer.json
Created October 14, 2012 16:16
OAuth2 client example
{
"require": {
"lncd/oauth2-facebook": "*",
"slim/slim": "2.*"
},
"minimum-stability": "dev"
}
@max-mapper
max-mapper / readme.md
Last active October 12, 2015 10:17
introduction to node
@philsturgeon
philsturgeon / composer.json
Created July 11, 2013 15:16
Composer Dev Requirements
{
"require": {
"laravel/framework": "4.0.*",
},
"require-dev": {
"behat/behat": "2.4.*",
"mockery/mockery": "0.7.*",
"fzaninotto/Faker": "1.2.*",
"pdepend/pdepend" : "1.1.*",
@peterjmit
peterjmit / doctrine_cache_driver.php
Created March 6, 2012 17:47
Get the Result Cache from the doctrine entity manager
<?php
class Foo
{
private $_em;
public function __construct($entity_manager)
{
$this->_em = $entityManager;
}
@laracasts
laracasts / ex.php
Last active January 27, 2016 13:08
So you want to allow one user to "follow" another user (like Twitter-style). Using Laravel and Eloquent, what's your preference?
<?php
// Option 1: the follow method immediately references the relationship and saves it.
class User extends Eloquent {
public function follows()
{
return $this->belongsToMany(self::class, 'follows', 'follower_id', 'followed_id');
}
@lucadegasperi
lucadegasperi / Vagrantfile
Created September 28, 2014 20:10
Homestead Plus
VAGRANTFILE_API_VERSION = "2"
path = "#{File.dirname(__FILE__)}"
require 'yaml'
require path + '/scripts/homestead.rb'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
Homestead.configure(config, YAML::load(File.read(path + '/Homestead.yaml')), Vagrant.has_plugin?('vagrant-hostsupdater'))
end
@treyrich
treyrich / Example.js
Last active May 30, 2017 20:36
This is an AngularJS provider to communicate with a Sails.js backend via Socket.IO.After searching for way too long for a way to interface with the Sails.js client-side SDK included in new Sails projects via AngularJS I decided to write a drop in replacement for the AngularJS $http provider.Although this isn't a full replacement it includes a nu…
angular.module("MyApp", ["SocketProvider"])
.controller("MyController", ["$scope", "socket", function($scope, socket) {
// Fetch initial data
$scope.person = null;
socket.get("/person/1").success(function(data) {
$scope.person = data;
}).error(function() {
@clawfire
clawfire / bcrypt.class.php
Created June 7, 2012 08:23
Bcrypt Class
<?php
class Bcrypt
{
private $rounds;
public function __construct($rounds = 12)
{
if (CRYPT_BLOWFISH != 1) {
throw new Exception("bcrypt not supported in this installation. See http://php.net/crypt");
}