Prev PageNext Page
How to Generate a UUID in PHP 7
Here is a little snippet for generating a UUID in PHP 7 function uuid(){ $data = random_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); $data[8] = chr(ord($data[8]) & 0x3f | 0x80); return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_...
Written by Sean Behan on 10/26/2017
Apache Rewrite Rule for Mapping to index.php in Sub Folders
Below is an example URL structure with rewrite rules using an Apache .htaccess file. GET /a/ => a/index.php GET /a/b/ => a/b/index.php GET /a/b/c/ => a/b/index.php This URL mapping will give you pretty URLs in PHP without needing t...
Written by Sean Behan on 10/20/2017
Manual ManyToMany Through with Django's ORM
Here is a code snippet that demonstrates how to set up a __ManyToMany through__ relationship in Django. In Rails, the equivalent would be called a __has_many through__ association. If you set the __through__ argument on the ManyToManyField, Django wil...
Written by Sean Behan on 07/21/2017
How to Read Response Body HTML with Javascript Fetch Method with React Native
In React Native you see a lot of tutorials and articles using the `fetch` method when interacting with `JSON` APIs. It's great for this and the the pattern looks like this fetch(url).then((resp)=>{ return resp.json() }).then((json)=>{ console.log(json...
Written by Sean Behan on 07/17/2017
How to Fix Raw query must include the primary key with Django ORM
When running raw SQL queries in Django you must include a primary key otherwise an invalid query exception is raised. Normally this is fine but when running more complex queries a primary key may not be available or even make sense. There is a simple ...
Written by Sean Behan on 07/15/2017
Simple SQL for Counting New Signups
Here is a little snippet that will return new signups (or new records) for today select id, email, created_at::date date from signups where email not in (select distinct email from signups where created_at < current_date)
Written by Sean Behan on 07/13/2017
How to Find An SQLite Database with React Native and the iPhone Simulator.
I spent a few hours digging around my file system using `find` and `grep` hunting for my SQLite database that the iPhone Simulator was using for my React Native project. And no luck. But I found a simple solution was to use `react-native log-ios` and ...
Written by Sean Behan on 06/29/2017
Active Admin Rails 5 undefined method per_page_kaminari
If you run into this error in development, using Rails 5 and Active Admin NoMethodError - undefined method `per_page_kaminari' Try the following. First, make sure you have an initializer in your application. # in config/initializers/kamina...
Written by Sean Behan on 04/27/2017
Regex for Extracting URLs in Plain Text
Here is a Regex for extracting URLs from text. However, these links will not already be hyperlinked or source attribtues from images or iframes. This example is in PHP. I was trying to format a Wordpress page to auto hyperlink but preserve embeded ima...
Written by Sean Behan on 04/14/2017
I Just Published My First PHP Package HTMLXPATH
I just wrote and published my first PHP package on Packagist.com. It's available on [packagist.org](https://packagist.org/packages/htmlxpath/htmlxpath) and the source code is on [github](https://github.com/seanbehan/htmlxpath). To install the package u...
Written by Sean Behan on 03/28/2017
Prev PageNext Page