Skip to content

Instantly share code, notes, and snippets.

View dossy's full-sized avatar
🍪
derping around

Dossy Shiobara dossy

🍪
derping around
View GitHub Profile
@duncansmart
duncansmart / progressive-ace.htm
Created March 28, 2013 23:29
Integrating ACE Editor in a progressive way
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
@killercup
killercup / pandoc.css
Created July 3, 2013 11:31
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@sstur
sstur / dom-to-json.js
Last active October 8, 2023 04:17
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
let propFix = { for: 'htmlFor', class: 'className' };
let specialGetters = {
style: (node) => node.style.cssText,
};
let attrDefaultValues = { style: '' };
let obj = {
nodeType: node.nodeType,
};
if (node.tagName) {
@timusg
timusg / keepalived-eip-switch.erb.sh
Last active October 20, 2016 21:01
keepalived notification script for switch elastic ip, helpful to setup highly available haproxy in ec2/VPC
#!/bin/bash
export EC2_HOME=/usr/local/share/ec2_tools/
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:$EC2_HOME/bin
INSTANCEID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
case "$1" in
MASTER)
logger triggering notify master event
@davepeck
davepeck / oops.c
Created February 22, 2014 10:07
iOS 7.0.6 "Security Content"
static OSStatus
SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams,
uint8_t *signature, UInt16 signatureLen)
{
OSStatus err;
SSLBuffer hashOut, hashCtx, clientRandom, serverRandom;
uint8_t hashes[SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN];
SSLBuffer signedHashes;
uint8_t *dataToSign;
size_t dataToSignLen;
@dossy
dossy / jquery-ui-require.js
Created April 7, 2014 15:12
Loading just jquery.ui.resizable with requireJS
<script type="text/javascript">
// http://matznermatzner.de/en/bernd/2013/11/loading-non-amd-modules-requirejs-part-1-jquery-ui/
requirejs.config({
paths: {
'jquery.ui.core': 'lib/jquery-ui/1.10.4/ui/minified/jquery.ui.core.min',
'jquery.ui.mouse': 'lib/jquery-ui/1.10.4/ui/minified/jquery.ui.mouse.min',
'jquery.ui.resizable': 'lib/jquery-ui/1.10.4/ui/minified/jquery.ui.resizable.min',
'jquery.ui.widget': 'lib/jquery-ui/1.10.4/ui/minified/jquery.ui.widget.min',
},
shim: {
@ashrithr
ashrithr / readme.md
Last active January 14, 2025 07:49
Installing ELK on a single machine

Installing ELK (CentOS)

This is a short step-by-step guide on installing ElasticSearch LogStash and Kibana Stack on a CentOS environment to gather and analyze logs.

I. Install JDK

rpm -ivh https://dl.dropboxusercontent.com/u/5756075/jdk-7u45-linux-x64.rpm
@dossy
dossy / screencapture.sh
Created November 25, 2014 15:22
Capture screen and convert to 16 color grayscale on OSX
# Because I know I'll forget this when I need it again, I'm documenting it here.
screencapture -x -C -T0 cap.png; (pngtopnm cap.png | ppmtopgm | pnmquant 16 | pnmtopng > cap-bw.png) >/dev/null 2>&1
@jtsternberg
jtsternberg / db.php
Last active October 20, 2022 19:12
Simplified WordPress DB drop-in replacement for persistent database connections
<?php
/**
* Simplified WordPress DB drop-in replacement for persistent database connections
* (If https://core.trac.wordpress.org/attachment/ticket/31018/31018-2.diff gets into core)
*
* Actual working version right now would look like: https://gist.github.com/jtsternberg/eec4ab95e11ce9be4807
*
* WordPress Trac Ticket {@link https://core.trac.wordpress.org/ticket/31018}
*/
@rveitch
rveitch / wordPress_table_pagination_example.php
Created July 30, 2015 01:44
WordPress Table Pagination Example
<?php
global $wpdb;
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
$limit = 5;
$offset = ( $pagenum - 1 ) * $limit;
$entries = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}posts LIMIT $offset, $limit" );
echo '<div class="wrap">';