Skip to content

Instantly share code, notes, and snippets.

View patrickcurl's full-sized avatar

Patrick Curl patrickcurl

View GitHub Profile
<?php
function getBook($isbn){
$region = "com";
$method = 'GET';
$host = 'webservices.amazon.'.$region;
$uri = '/onca/xml';
$ass_tag = Config::get('env_vars.amazon_ass_tag');
$public_key = Config::get('env_vars.amazon_public_key');
@patrickcurl
patrickcurl / SupplyOrdersController.php
Created October 29, 2013 16:13
What am I missing to get this to update db on click of link?
<?php
namespace api;
use Illuminate\Support\Facades\View;
use Illuminate\Routing\Controllers\Controller;
class SupplyOrdersController extends \Controller {
protected static $restful = true;
public function update($id){
[2014-01-27 09:23:09.563241] I [glusterd-volume-ops.c:83:glusterd_handle_create_volume] 0-glusterd: Received create volume req
[2014-01-27 09:23:09.564165] I [glusterd-utils.c:285:glusterd_lock] 0-glusterd: Cluster lock held by c1e014dd-5de5-4d04-8bcb-e4f9754503e3
[2014-01-27 09:23:09.564191] I [glusterd-handler.c:463:glusterd_op_txn_begin] 0-management: Acquired local lock
[2014-01-27 09:23:09.565151] I [glusterd-rpc-ops.c:548:glusterd3_1_cluster_lock_cbk] 0-glusterd: Received ACC from uuid: c9919ca3-6e14-480b-bd20-ed0d63a66d95
[2014-01-27 09:23:09.565220] I [glusterd-rpc-ops.c:548:glusterd3_1_cluster_lock_cbk] 0-glusterd: Received ACC from uuid: 27aece02-873c-4cd7-bc31-eb84b659bed4
[2014-01-27 09:23:09.566008] W [glusterd-utils.c:4920:mkdir_if_missing] 0-: Failed to create the directory /var/export/www
[2014-01-27 09:23:09.566035] E [glusterd-op-sm.c:1999:glusterd_op_ac_send_stage_op] 0-: Staging failed
[2014-01-27 09:23:09.566055] I [glusterd-op-sm.c:2039:glusterd_op_ac_send_stage_op] 0-glusterd: Sent op r
App::uses('CsvFileObject', 'Lib');
App::uses('CsvIterator', 'Lib');
//...
public function upload() {
$file = $this->data['Book']['file'];
if ($file['error'] === UPLOAD_ERR_OK) {
if (move_uploaded_file($file['tmp_name'], APP.'webroot/uploads'.DS.$file['name'])) {
$path = APP.'webroot/uploads'.DS.$file['name'];
@patrickcurl
patrickcurl / error
Created February 11, 2014 19:55
Laravel upload files outside of laravel app directory.
Symfony \ Component \ HttpFoundation \ File \ Exception \ FileException
Unable to create the "/home/rahl/www/recycleabook.com/files/" directory
open: /home/rahl/www/recycleabook.com/rab/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php
return $target;
}
protected function getTargetFile($directory, $name = null)
{
if (!is_dir($directory)) {
if (false === @mkdir($directory, 0777, true)) {
@patrickcurl
patrickcurl / models.py
Created February 20, 2014 20:08
Polls project django tutorial, error during testing.
from django.db import models
import datetime
from django.utils import timezone
# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
<?php
Route::get('/testbal', function(){
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "TEST-MP4ILBwvLbXhtYjRrGA6qlwx";
$m = Balanced\Marketplace::mine();
var_dump($m);
//$marketplace = Balanced\Marketplace::mine();
@patrickcurl
patrickcurl / User.rb
Created May 6, 2015 08:35
User model
class User < ActiveRecord::Base
validates_confirmation_of :password
before_save :encrypt_password
def encrypt_password
self.password_salt = BCrypt::Engine.generate_salt
self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)
end
def self.auth(email, password)
// Bonfire: Meet Bonfire
// Author: @patrickcurl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-meet-bonfire#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function meetBonfire(argument) {
// Good luck!
console.log("you can read this function's argument in the developer tools", argument);
return true;
// Bonfire: Reverse a String
// Author: @patrickcurl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-reverse-a-string#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function reverseString(str) {
return str.split('').reverse().join('');
}
reverseString("hello");