Skip to content

Instantly share code, notes, and snippets.

(在家工作) Working from home

Lasse R LasseRafn

(在家工作) Working from home
View GitHub Profile
iben12 /
Last active Jun 20, 2020
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.

rap2hpoutre / circle.yml
Created May 19, 2016
Circle CI example for Laravel
View circle.yml
version: 7.0.3
fideloper /
Last active Jun 26, 2020
Update curl on Ubuntu 14.04
#! /usr/bin/env bash
# Install any build dependencies needed for curl
sudo apt-get build-dep curl
# Get latest (as of Feb 25, 2016) libcurl
mkdir ~/curl
cd ~/curl
tar -xvjf curl-7.50.2.tar.bz2
entropiae /
Last active Mar 24, 2020
git: how to solve "SSLRead() return error -9806" in OSX using brew
$ brew remove git
$ brew remove curl
$ brew install openssl
$ brew install --with-openssl curl
$ brew install --with-brewed-curl --with-brewed-openssl git
sebastianseilund /
Last active Sep 3, 2018
Simple documentation for the beta of API v2. We are working on getting our new real API docs online.
malarkey / Contract Killer
Last active Jul 9, 2020
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

View ios-8-web-app.html
<!doctype html>
<!-- -->
<title>iOS 8 web app</title>
dave1010 / strip_word_html.php
Created Nov 12, 2010
Strip MS Word HTML. From
View strip_word_html.php
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
//replace MS special characters first
$search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
$replace = array('\'', '\'', '"', '"', '-');
$text = preg_replace($search, $replace, $text);
//make sure _all_ html entities are converted to the plain ascii equivalents - it appears
//in some MS headers, some html entities are encoded and some aren't
You can’t perform that action at this time.