Skip to content

Instantly share code, notes, and snippets.

@DaveRandom
DaveRandom / script.js
Last active June 6, 2018 09:36
Tweet icon for Jeeves in SO chat
// ==UserScript==
// @name Tweet icon for Jeeves in SO chat
// @namespace http://room11.org/
// @version 1.0
// @description @PeeHaa sucks
// @author @DaveRandom
// @match *://chat.stackoverflow.com/rooms/*
// @grant none
// ==/UserScript==
@cgray
cgray / route-to-url.php
Created April 4, 2017 03:54
Given an array of placeholder values and a FastRoute uri definition build a url
<?php
function buildUrl($uri, array $params) {
$matches = [];
$pattern = '{\s* ([a-zA-Z_][a-zA-Z0-9_-]*) \s*(?:: \s* ([^{}]*(?:\{(?-1)\}[^{}]*)*))?\}';
$optionalSegments = '\[.*'.$pattern.'\]';
$uri = preg_replace_callback('~'.$optionalSegments.'~x', function($match) use ($params) {
$uri = trim($match[0], '[]');
if (isset($params[$match[1]])) {
@DaveRandom
DaveRandom / .gitignore
Created August 2, 2016 10:07
Default repository layout - PHP web application
vendor # ignore composer data
# ignore PHP Storm config
# you may want to ignore your IDE config and you may want to commit it, up to you
.idea
@rlemon
rlemon / bulk-trash.js
Last active July 23, 2017 20:34
Bulk Trash
var btn = $('<button class="button">Bulk Trash</button>'),
room = document.forms[0].elements.room.value;
btn.on('click', function() {
var modal = $('<div><h4>Trash Who?</h4></div>'),
$users = $('#present-users:not(.more)').clone();
modal.append($users).addClass('popup room-popup').css({
bottom: btn.position().top,
left: btn.position().left
}).on('click', function(e) {
if (confirm("Would you like to trash all posts by " + e.target.title)) {
@gooh
gooh / responses.js
Created January 12, 2016 13:46
Swordfighting for Might Pirates; requires https://www.npmjs.com/package/hubot-response
[
{
"match": "You fight like a Dairy Farmer!",
"description": "swordfighting for might pirates",
"listener": "hear",
"response": "How appropriate! You fight like a cow!"
},
{
"match": "This is the END for you, you gutter crawling cur!",
"description": "swordfighting for might pirates",
@joashp
joashp / PushNotifications.php
Last active June 3, 2024 15:38
Simple PHP script to send Android Push Notification, iOS Push Notification and Windows Phone 8 Push Notification
<?php
// Server file
class PushNotifications {
// (Android)API access key from Google API's Console.
private static $API_ACCESS_KEY = 'AIzaSyDG3fYAj1uW7VB-wejaMJyJXiO5JagAsYI';
// (iOS) Private key's passphrase.
private static $passphrase = 'joashp';
// (Windows Phone 8) The name of our push channel.
private static $channelName = "joashp";
@rlemon
rlemon / autobin.js
Last active August 29, 2015 14:11
auto bin gifs.
// ==UserScript==
// @name SO Chat room gif autobinner
// @author Robert Lemon
// @version 0.0.32
// @namespace
// @description make rooms not suffer gifs
// @include http://chat.stackoverflow.com/rooms/*
// ==/UserScript==
(function(global) {
"use strict";
@rlemon
rlemon / keepaliveso.user.js
Last active August 29, 2015 14:11
SO Chat room KeepAlive Plus
// ==UserScript==
// @name SO Chat room KeepAlive Plus
// @author Robert Lemon
// @version 0.0.3
// @namespace
// @description make rooms not die
// @include http://chat.stackoverflow.com/rooms/*
// @include http://chat.stackexchange.com/rooms/*
// @include http://chat.meta.stackexchange.com/rooms/*
// ==/UserScript==
@roccolucatallarita
roccolucatallarita / readme.txt
Created April 7, 2014 21:14
Create route in titanium map module
Create a file in your lib folder, like **rootproject**/lib/routes.map.js
load the module in your file and initialize with the data:
var jsonCoordinates = {
'destination': dest.latitude + ',' + dest.longitude,
'origin': origin.latitude + ',' + origin.longitude,
};
var routes = require("routes.map")(jsonCoordinates, mapview);
@plentz
plentz / nginx.conf
Last active July 2, 2024 13:20
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048