Skip to content

Instantly share code, notes, and snippets.

View SparK-Cruz's full-sized avatar

Cruz SparK-Cruz

  • Brasil
View GitHub Profile
@SparK-Cruz
SparK-Cruz / Database.php
Created April 4, 2018 15:49
Connect LessQL to the same database as Phinx
<?php
use Symfony\Component\Config\FileLocator;
use Phinx\Config\Config;
use Phinx\Db\Adapter\AdapterFactory;
class Database extends \LessQL\Database {
const PHINX_FILE = 'phinx.yml';
public function __construct($env = null) {
$config = $this->readPhinxConfig($env);
@SparK-Cruz
SparK-Cruz / fillable.php
Last active June 11, 2018 17:13
Accessible attributes trait for mass assignment in php
<?php
trait Fillable {
public function __construct($attributes) {
$this->fill($attributes);
}
public function fill($attributes) : void {
foreach((array)$attributes as $key => $value) {
if (!property_exists($this, $key))
continue;
export const waitFor = function(search :function, callback :function, interval = 500) :void {
const checkLoop = setInterval(function () {
let element = search();
if (typeof element === 'undefined' || element === null) {
return;
}
clearInterval(checkLoop);
callback(element);
@SparK-Cruz
SparK-Cruz / Furnace.js
Created April 12, 2017 22:14
A tiny lib for managing cookies
;(function(){
// Cookie management
window.Furnace = {
cookie: function(name) {
function splitCookie() {
if (document.cookie.length == 0) {
return null;
}
var start = document.cookie.indexOf(name + "=");
@SparK-Cruz
SparK-Cruz / defer.js
Created March 5, 2015 17:57
Function deferring for javascript
Function.prototype.defer = function(thisObj, parameters){
if (typeof parameters == "undefined")
parameters = [];
if (typeof window.deferredActionsList === "undefined")
window.deferredActionsList = [];
if (typeof window.__deferredActionsRunner === "undefined")
window.__deferredActionsRunner = setTimeout(function(){
for(var key in window.deferredActionsList){
@SparK-Cruz
SparK-Cruz / placeholder.js
Last active August 29, 2015 13:56
jQuery plugin for html5 placeholder backward compatibility
/**
* Placeholder - jQuery Plugin
* Emulates the html5 placeholder effect on older browsers
*
* Copyright (c) 2014 Roger 'SparK' Rodrigues da Cruz
*
* Version: 0.3 (14/02/2014)
* Requires: jQuery
*
* Dual licensed under GPL and MIT:
@SparK-Cruz
SparK-Cruz / Class.js
Last active September 29, 2015 07:57
JavaScript Class boilerplate
/**
* JavaScript Class Definition
*
* Author: Roger "SparK" Rodrigues da Cruz
* Licence: Free, no credits, no references, just use it if you feel like.
*/
;MyClass = (function(){
var C = function(){ return constructor.apply(this,arguments); }
var p = C.prototype;