Skip to content

Instantly share code, notes, and snippets.

<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->
This file has been truncated, but you can view the full file.
var ffi = require('ffi');
var
int8 = ffi.types.int8,
uint8 = ffi.types.uint8,
int16 = ffi.types.int16,
uint16 = ffi.types.uint16,
int32 = ffi.types.int32,
uint32 = ffi.types.uint32,
int64 = ffi.types.int64,
@a9
a9 / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@a9
a9 / mysql.php
Last active August 29, 2015 14:17 — forked from lbp0200/mysql.php
<?php
try {
$dbh = new PDO('mysql:host=localhost;dbname=mytest', 'root', '123', array(
PDO::ATTR_PERSISTENT => true));
$rows = array(
array(null, 'def', time()),
array(null, 'def', time()),
array(null, 'def', time()),
/**
* Creates an XPath from a node (currently not used inside this Class (instead FormHTML.prototype.generateName is used) but will be in future);
* @param {string=} rootNodeName if absent the root is #document
* @return {string} XPath
*/
$.fn.getXPath = function(rootNodeName){
//other nodes may have the same XPath but because this function is used to determine the corresponding input name of a data node, index is not included
var position,
$node = this.first(),
nodeName = $node.prop('nodeName'),
/** @jsx React.DOM */
var MyComponent = React.createClass({
render: function() {
// Defaults in case the props are undefined. We'll have a solution for this
// soon that is less awkward.
var perMinute = this.props.perMinute || '-';
var perDay = this.props.perDay || '-';
return (
<div>
<h3>Clickouts</h3>
@a9
a9 / DDSImageParser.cs
Created December 9, 2016 04:57 — forked from soeminnminn/DDSImageParser.cs
Read DDS image in C# way. Converted from "[il_dds.c](https://github.com/DentonW/DevIL/blob/master/DevIL/src-IL/src/il_dds.c)" (DevIL).
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.IO;
namespace S16.Drawing
{
#region DDSImage Class
@a9
a9 / nginx.conf
Created July 25, 2017 15:59 — forked from micho/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf:
@a9
a9 / CreateJob.sh
Created April 24, 2018 08:35 — forked from stuart-warren/CreateJob.sh
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder