Skip to content

Instantly share code, notes, and snippets.

View thelebster's full-sized avatar
:octocat:
Do nothing, it is ok.

Anton Lebedev thelebster

:octocat:
Do nothing, it is ok.
View GitHub Profile
<?php
$zend_path = libraries_get_path('Zend');
set_include_path(get_include_path() . PATH_SEPARATOR . $zend_path);
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
?>
<?php
function MYMODULE_generate_barcode128($string, $rebuild = FALSE) {
$filepath = 'barcodes';
$filename = "{$filepath}/" . md5($string) . ".png";
// First check if the images already exists.
if (!file_exists(file_default_scheme()."://{$filename}") || $rebuild) {
<?php
/**
* Google Url Shortener http://goo.gl/xxxxx
*/
function MYMODULE_urlshortener_get_short_url($url) {
$api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$api_url = 'https://www.googleapis.com/urlshortener/v1/url/?key=' . $api_key;

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
@thelebster
thelebster / gist:8797865
Created February 4, 2014 03:48
Using gzip and gunzip with mysql to import/export backups
Exporting:
mysqldump -u user -p database | gzip > database.sql.gz
Importing:
gunzip < database.sql.gz | mysql -u user -p database
@thelebster
thelebster / API.md
Created February 6, 2014 08:59 — forked from iros/API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

function ithra_softlayer_download_file($account, $fid) {
$file = db_select('ithra_softlayer_objectstorage', 'os')
->fields('os')
->condition('uid', $account->uid, '=')
->condition('fid', $fid, '=')
->execute()->fetchObject();
if (!$file) {
drupal_not_found();
<?php
error_reporting(E_ALL);
require realpath(dirname(__FILE__)) . '/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
// DEMO ONLY (potentially unsafe)
$data = json_decode($_POST['json']);
$key = $_POST['key'];
var User = require('../app/models/user');
var Auth = require('./middlewares/api_auth.js');
module.exports = function(app, passport){
app.get('/api/auth/fb', function(req, res, next) {
passport.authenticate('facebook-token', function(err, user, info) {
if (err) {
return next(err); // will generate a 500 error