Skip to content

Instantly share code, notes, and snippets.

View ChristopherDosin's full-sized avatar
:octocat:
Out sick

Christopher Dosin ChristopherDosin

:octocat:
Out sick
View GitHub Profile
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@ChristopherDosin
ChristopherDosin / php_object_to_array.php
Created May 3, 2017 21:34 — forked from victorbstan/php_object_to_array.php
recursively cast a PHP object to array
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);
@ChristopherDosin
ChristopherDosin / Manager.php
Created May 8, 2016 18:45
PHP - WebPush Manager
<?php
namespace GSS\Component\Push;
use Symfony\Component\DependencyInjection\Container;
class Manager
{
const GCM_URL = 'https://android.googleapis.com/gcm/send/';
const MOZ_URL = 'https://updates.push.services.mozilla.com/push/v1/';
private $db;
<?php
/**
* An helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.0.16 on 2015-03-16.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
// @foreach(array_chunk($posts->all(), 3) as $postSet)
@foreach(array_chunk($posts, 3) as $postSet)
<div class="row"> <!-- this div will surround every three posts -->
@foreach($postSet as $post)
<h3>{{ $post['title'] }}</h3>
@endforeach
</div>
@endforeach
jQuery( document ).ready( function( $ ) {
console.log("start");
$( '#form-add-setting' ).on( 'submit', function() {
//.....
//show some spinner etc to indicate operation in progress
//.....
console.log("Submitting");
$.post(
$( this ).prop( 'action' ),