Skip to content

Instantly share code, notes, and snippets.

View mrkmg's full-sized avatar

Kevin mrkmg

View GitHub Profile
@mrkmg
mrkmg / blade_stolz_assets.php
Last active August 29, 2015 14:10
Adds @asset, @assetjs, @assetcss to blade templates
<?php
// Adds @asset tag to blade templates;
// USAGE: @asset('path/to/file.css|js')
Blade::extend(function($view, \Illuminate\View\Compilers\BladeCompiler $compiler)
{
$pattern = $compiler->createMatcher('asset');
return preg_replace($pattern, '<?php Assets::add$2; ?>', $view);
});
@mrkmg
mrkmg / TurbineMonitor.lua
Created March 10, 2015 12:54
BigReactors - Turbine Monitor
-- TurbineMonitor
-- Made By: MrKMG <mrkmg.com>
--
-- This program will keep your turbines up to speed and turn
-- the coil on and off as needed.
--
-- To Use:
--
-- Attach as many Turbines and Monitors as you would like via
-- wired modems. Monitors will all display the same information
@mrkmg
mrkmg / jquery.onhold.js
Created October 4, 2011 20:21
jQuery On Hold event
(function( $ ){
$.fn.onHold= function(time,action) {
this.data('onHold_selected',false);
this.mousedown(function(){
$(this).data('onHold_selected',true);
var object = this;
setTimeout(function(){
if($(object).data('onHold_selected')){
action();
}
@mrkmg
mrkmg / axel.scpt
Created February 13, 2012 21:17
AXEL Apple Script
--Written by Kevin Gravier
--Edit and redistribute as you please but leave this header.
property lastURL : "http://link.to.file"
property lastThreads : 4
set link to text returned of (display dialog "What do you want to download?" buttons {"OK"} default button 1 default answer lastURL with icon 1)
set lastURL to link
set threads to text returned of (display dialog "How many threads?" buttons {"OK"} default button 1 default answer lastThreads with icon 1)
set lastThreads to threads
@mrkmg
mrkmg / JApi.php
Created May 11, 2012 14:08
JApi, short for JSON API, is an action handler for Yii.
<?php
/**
* JApi, short of JSON API, is an action handler for Yii.
*
* JApi maps requests in the form ?r=controller/japu&action=method to controller->japiMethod. Then, anything returned from
* japiMethod is encoded in JSON and sent to the client. Parameters in the function are mapped to _GET varibles. JApi
* follows the requirments of the parameters, such as optional and required.
*
* EXAMPLE:
in ExampleController.php
@mrkmg
mrkmg / tclock.sh
Created May 16, 2012 19:17
Floating Clock for linux (tclock)
#!/bin/sh
### Floating Clock ######################################################
# Created by Scott Garrett https://github.com/Wintervenom #
# Found via https://bbs.archlinux.org/viewtopic.php?pid=557778#p557778 #
# Maintained By Kevin Gravier <kevin@mrkmg.com> #
#########################################################################
cols=`tput cols`
@mrkmg
mrkmg / TPM.php
Last active October 10, 2015 19:59
Tick Per Minute Class. You can add a tick at anytime, and then later calculate the average ticks per min
<?php
class TPM {
public $useCtime = true; //If true, use current time for tpm calculation. If false, use last tick.
public $purgeOlderThan = 15; //Time in minutes to purge old data
private $ticks = array();
//Add a tick
public function tick(){
@mrkmg
mrkmg / numweekendsbyyear.php
Created December 10, 2012 22:17
Calculate number of weekends per month, quarter, and year
#!/usr/bin/env php
<?php
if(!isset($argv[1]) or !is_numeric($argv[1]) or strlen($argv[1]) != 4){
$cmd = $argv[0];
echo <<<out
See the number of weekend in each month, quarter, and yearly.
Usage: $cmd yyyy
var Promise = require("bluebird");
function doSomething()
{
return Promise
.try(function ()
{
return task1();
})
.then(function (result)
// ==UserScript==
// @name New Coffee-Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description shows how to use coffeescript compiler
// @author You
// @require http://coffeescript.org/extras/coffee-script.js
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @match https://speed.cd/browse.php*
// ==/UserScript==