Skip to content

Instantly share code, notes, and snippets.

View twright's full-sized avatar

Thomas Wright twright

View GitHub Profile
[Device]
Name=Lenovo ThinkVision m14t
ModelName=
DeviceMatch=usb:2d1f:524c
Class=ISDV4
Width=12
Height=7
IntegratedIn=Display
Styli=@isdv4-aes;
<snippet>
<description>Insert a LaTeX environment</description>
<content><![CDATA[
\\begin{${1:env}}
$2
\\end{$1}$3
]]></content>
<tabTrigger>\begin</tabTrigger>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>env</tabTrigger> -->
@twright
twright / script.js
Created October 3, 2012 15:52 — forked from radiancelux/gist:3815701
Build-a-Board Preview
<style>
div.innerpreview
{
height: 350px;
width: 350px;
position: float;
background-color:white;
border: 1px solid #E3E3E3;
border-radius: 5px 5px 5px 5px;
/* Rotate div */
@twright
twright / field-placeholder.js
Created September 27, 2012 00:16
Add a placeholder to a textfield
jQuery(document).ready(function() {
// Select the field we want to add the behaviour to
var field = jQuery('#respond input[type="text"][name="ecf_4"]');
// What text do we want to
var placeholder_text = 'your placeholder';
var text_changed = false;
if ('placeholder' in field[0])
/* Modern browsers natively support text field placeholders */
field.attr('placeholder', placeholder_text);
@twright
twright / zfish.filter.php
Created September 25, 2012 22:35 — forked from eleclerc/zfish.filter.php
ZendFramework-ish filter for PHP_Beautifier
<?php
/**
* A ZendFramework-ish filter for PHP_Beautifier
*
* This file have to go in:
* /path/to/pear/php/Beautifier/Filter/
*
* Use it in conjunction with Pear() and NewLines() filters:
* php_beautifier --input "/path/to/your-file.php" --filter="Pear() zfish() NewLines(after=T_DOC_COMMENT)"
*
@twright
twright / script.js
Created September 25, 2012 03:36
Combine images
jQuery(document).ready(function() {
// Add the event listainer to each field
addEventListeners('css selector of fields');
});
function changeSrc(img, url) {
// Set the src attribute of the image
image.attr('src', url);
}
@twright
twright / example-plugin.php
Created September 25, 2012 03:04
Basic outline of a wordpress plugin
<?php
class ExampleWordpressPlugin {
const PLUGIN_NAME = 'example-plugin';
const PLUGIN_VERSION = '0.01';
/**
* The constructor of the class.
*/
public function __construct() {
$this->hooks();
@twright
twright / gist:3779704
Created September 25, 2012 02:49
Price updating js from a WordPress theme
function checkstock(attval)
{
var attrs = attval.split(',');
document.getElementById("cat").value = attrs[0];
if(eval('document.getElementById("shoppingcart_button_1")'))
{
document.getElementById("shoppingcart_button_1").style.display="";
}
if(eval('document.getElementById("shoppingcart_outofstock_msg1")'))
{
@twright
twright / ecf_get_field_value.php
Created September 24, 2012 00:41
Get the value of an ECF field for a comment
<?php
/**
* Get the value of an Extra Comment Field.
* @param string $ref The ref code of the field to retrieve e.g. 'ecf_3'.
* @param integer $comment_id The id of the comment.
* @return string|null The value of the user's response to the field.
* @see ecfdb::get_comment_data()
*/
function ecf_get_field_value( $ref, $comment_id = null ) {
// Make use of the global variable containing the Extra Comment Fields
@twright
twright / makefile
Created September 22, 2012 01:14
C Programming Language -- Calculator Makefile
CC = gcc
CFLAGS = -Wall -pedantic -O3 -flto -fno-builtin -unsafe-loop-optimizations -Wunsafe-loop-optimizations -ffast-math -funsafe-math-optimizations -msse3
OBJECTS = bufgetch.o getop.o stack.o
calc:
$(CC) -lm -fwhole-program $(CFLAGS) -o calc $(OBJECTS)
calc.o: getop.o stack.o
getop.o: bufgetch.o