Skip to content

Instantly share code, notes, and snippets.

View frankdejonge's full-sized avatar

Frank de Jonge frankdejonge

View GitHub Profile
protected static function delete_translations($obj)
{
$translation = static::find(function($query) use($obj){
$query->where('parent_id', $obj->id);
});
foreach($translation as $row)
{
$row->delete();
}
public function getByLatLng($lat, $lng, $range = 5000 /* KM */, $earthRadius = 6378 /* Unit Earth Radius */) {
\Config::load('db');
$mongoConf = \Config::get('mongo');
$monga = \Monga::connection('mongodb://' . $mongoConf['default']['hostname'] . ':27017');
$database = $monga->database($mongoConf['default']['database']);
$nameCache = 'company_get_by_' . $lat . '_' . $lng;
try {
@frankdejonge
frankdejonge / rename.php
Last active December 24, 2015 15:09 — forked from AmyStephen/rename.php
<?php
$objects = new RecursiveIteratorIterator
(new RecursiveDirectoryIterator(__DIR__),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($objects as $path => $fileObject) {
if ( ! is_dir($fileObject)) {
continue;
@frankdejonge
frankdejonge / Curry.php
Last active December 28, 2015 16:28
PHP Functional Currying
<?php
function __curry($callback, Reflector $reflector = null, $arguments = array(), $numArgs = null)
{
if ( ! $reflector) {
$reflector = new ReflectionFunction($callback);
}
if ($numArgs === null) {
$numArgs = $reflector->getNumberOfRequiredParameters();
@frankdejonge
frankdejonge / gist:8234108
Created January 3, 2014 07:14
Ansible setup for MailCatcher.me
---
- name: Commmon | MailUtils
apt: pkg=mailutils state=latest
- name: Commmon | sqlite3
apt: pkg=sqlite3 state=latest
- name: Commmon | libsqlite3-dev
apt: pkg=libsqlite3-dev state=latest
### Keybase proof
I hereby claim:
* I am FrenkyNet on github.
* I am frenkynet (https://keybase.io/frenkynet) on keybase.
* I have a public key whose fingerprint is 3ED4 AF00 97B3 C922 5340 D2F6 5276 297F FD01 F1D8
To claim this, I am signing this object:
---
suites:
some_suite:
namespace: Name\Space
psr4_prefix: Name\Space
var gulp = require('gulp');
var spawn = require('child_process').spawn;
var subprocess;
function refreshGulpfile() {
if (subprocess) subprocess.kill();
subprocess = spawn('gulp', ['watched-default'], {stdio: 'inherit'});
}
gulp.task('default', function () {
@frankdejonge
frankdejonge / gist:5c19f8e7ce329dbcc1ef
Created June 10, 2014 18:38
Flysystem and user downloads
<?php
$stream = $fs->readStream($file);
// send the right headers
header("Content-Type: " . $fs->getMimetype($file));
header("Content-Length: " . $fs->getSize($file));
header("Content-disposition: attachment; filename=\"" . basename($file) . "\"");
// dump the attachement and stop the script
<?php
use GuzzleHttp\Post\PostFile;
$request = $client->createRequest('POST', 'http://example.com/');
$postBody = $request->getBody();
$readStream = $flysystem->readStream($fileLocation);
$postBody->addFile(new PostFile('test', $readStream);
$response = $client->send($request);