Skip to content

Instantly share code, notes, and snippets.

🏠
(在家工作) Working from home

Lasse R LasseRafn

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

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
rap2hpoutre / circle.yml
Created May 19, 2016
Circle CI example for Laravel
View circle.yml
machine:
timezone:
Europe/Paris
php:
version: 7.0.3
environment:
ENVIRONMENT: testing
DB_URL: 127.0.0.1
@fideloper
fideloper / update_curl.sh
Last active Jun 26, 2020
Update curl on Ubuntu 14.04
View update_curl.sh
#! /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
wget http://curl.haxx.se/download/curl-7.50.2.tar.bz2
tar -xvjf curl-7.50.2.tar.bz2
@entropiae
entropiae / fix_git_sslread_9806.sh
Last active Mar 24, 2020
git: how to solve "SSLRead() return error -9806" in OSX using brew
View fix_git_sslread_9806.sh
$ brew remove git
$ brew remove curl
$ brew install openssl
$ brew install --with-openssl curl
$ brew install --with-brewed-curl --with-brewed-openssl git
@sebastianseilund
sebastianseilund / billy-api-v2-docs.md
Last active Sep 3, 2018
Simple documentation for the beta of API v2. We are working on getting our new real API docs online.
View billy-api-v2-docs.md
@malarkey
malarkey / Contract Killer 3.md
Last active Jul 9, 2020
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

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>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@dave1010
dave1010 / strip_word_html.php
Created Nov 12, 2010
Strip MS Word HTML. From php.net
View strip_word_html.php
<?php
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
{
mb_regex_encoding('UTF-8');
//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.