Skip to content

Instantly share code, notes, and snippets.

@a9
a9 / memcache.php
Last active December 14, 2015 19:58
Memcache
<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: " . $version . "<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
<?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>
function countLines(ele) {
var styles = window.getComputedStyle(ele, null);
var lh = parseInt(styles.lineHeight, 10);
var h = parseInt(styles.height, 10);
var lc = Math.round(h / lh);
console.log('line count:', lc, 'line-height:', lh, 'height:', h);
return lc;
}
@a9
a9 / buildandroid.sh
Created July 25, 2016 07:57
buildandroid.sh
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/