Skip to content

Instantly share code, notes, and snippets.

@jaggy
jaggy / tap.js
Created August 28, 2017 14:07
Higher order tap for javascript
function tap (object) {
return new Proxy(object, {
get: function (target, attribute) {
return function (...args) {
target[attribute].apply(target, args);
return target;
};
},
});
<?php
namespace App\Notifications\Channels;
use Illuminate\Notifications\Notification;
class Broadcast extends \Illuminate\Notifications\Channels\BroadcastChannel
{
/**
* Send the given notification.
<?php
use App\Repository;
class StarRepositoryController extends Controller
{
public function store(Repository $repository)
{
// star the repo.
}
pre {
font-size: 13px !important;
font-family: 'Operator Mono' !important;
line-height: 1.5 !important;
}
.cm-xml-comment {
font-style: italic !important;
}
<?php
$storage = getcwd() . '/logs/sql.log';
$logger = new \Monolog\Logger('sql');
$logger->pushHandler(new \Monolog\Handler\StreamHandler($storage), \Monolog\Logger::WARNING);
$patters = $placeholders = [];
$query = $this->toSql();
@jaggy
jaggy / hotkey_helpers.js
Created July 26, 2016 16:21 — forked from jiaaro/hotkey_helpers.js
Mac Automation – Javascript Hotkey helpers
// How to use:
// 1. Open "Script Editor" (requires OS X 10.10 Yosemite)
// 2. Change the language from "AppleScript" to "JavaScript"
// 3. Paste the code below and replace the safari example.
//
// More info:
// https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html
var sys_events = Application("System Events");
function replace_links(tweet) {
var pattern = /(http[s:\/a-zA-Z0-9\.\_]+)\b/gm;
return tweet.replace(pattern, '<a href="$1">$1</a>');
}
function replace_mentions(tweet) {
var pattern = /(\@(.+?))\b/gm;
var base_url = 'https://twitter.com/';
<?xml version="1.0"?>
<root>
<item>Workflow</item>
<item>
<name>Change PC Application Key (Menu Key)</name>
<item>
<name>Application Key to Alfred Launcher</name>
<identifier>remap.pc_application2alfred</identifier>
<autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::SPACE, ModifierFlag::COMMAND_L</autogen>
</item>
@jaggy
jaggy / first.php
Last active February 26, 2016 10:57
<?php
function createAccountFor($type, $name = null, $model) {
$parameters = [
'name' => $name,
'model_id' => $model->id,
];
return factory(Account::class, $type)->create($parameters);
}
@jaggy
jaggy / fp.js
Last active February 24, 2016 09:03
var personCurry = function (name) {
return function (greeting) {
return function (person) {
console.log(greeting + ', ' + person + '! My name is ' + name);
}
}
};
var jaggy = personCurry('Jaggy');
var greet = jaggy('Hi');