Skip to content

Instantly share code, notes, and snippets.

@JeremiahTolbert
JeremiahTolbert / ajax-filter.php
Created November 18, 2012 03:37
Laravel Ajax Filter for Controllers
<?php
//This part would be included in the controller itself like so:
class Articles_Controller extends Controller {
public function __construct() {
parent::__construct();
$this->filter('before', 'csrf')->on('post');
$this->filter('before', 'ajax')->only(array('index', 'show', 'update'));
}
<?php
/**
* Trait helps to allow for some limited overloading of
* methods in the class this is attached to.
*/
trait Overloader {
/**
@farinspace
farinspace / combos.php
Last active February 4, 2021 11:56
Recursive functions, I can never find exactly what I need in a pinch
<?php
function combos($data, &$all = array(), $group = array(), $val = null, $i = 0) {
if (isset($val)) {
array_push($group, $val);
}
if ($i >= count($data)) {
array_push($all, $group);
} else {
foreach ($data[$i] as $v) {
@jamiejohnsonkc
jamiejohnsonkc / net start & stop commands
Created August 11, 2018 23:22
net start / net stop #win, #cmd
net start [serviceName]
and
net stop [serviceName]
tell you whether they have succeeded or failed pretty clearly. For example
U:\>net stop alerter
The Alerter service is not started.
@dixonsiu
dixonsiu / convert_link.py
Last active April 27, 2021 20:22
Python scripts for Pandoc
@fnielsen
fnielsen / afinn.py
Last active May 6, 2021 11:41
Simplest sentiment analysis in Python with AFINN
#!/usr/bin/python
#
# (originally entered at https://gist.github.com/1035399)
#
# License: GPLv3
#
# To download the AFINN word list do:
# wget http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/6010/zip/imm6010.zip
# unzip imm6010.zip
#
@dixonsiu
dixonsiu / pandoc_filter_procedures.md
Last active June 9, 2021 01:15
How to convert markdown link to html using Pandoc

How to convert markdown link to html using Pandoc

Issue

Pandoc cannot convert a link's URL as expected.
Markdown:

[Document](./document.md)

HTML:

Document

@nebiros
nebiros / mb_str_pad.php
Created November 4, 2009 20:30
mb_str_pad
<?php
/**
* mb_str_pad
*
* @param string $input
* @param int $pad_length
* @param string $pad_string
* @param int $pad_type
* @return string
<?php
/**
*
* You can find the complete tutorial for this here:
* https://pluginrepublic.com/woocommerce-custom-fields
*
* Alternatively, check out the plugin
* https://pluginrepublic.com/wordpress-plugins/woocommerce-product-add-ons-ultimate/
*
@andytlr
andytlr / _description.md
Last active August 1, 2023 08:02
Convert SVG <polyline> to <path> so they can be animated with D3 etc.

Convert SVG polyline to path

Replace all instances of <polyline with <path and points=" with d="M.

 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1000px" height="1000px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
-<polyline fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" points="100.712,141.534 582.904,227.835 425.37,478.521
+