Skip to content

Instantly share code, notes, and snippets.

View Lax's full-sized avatar

Liu Lantao Lax

View GitHub Profile
# A quick and dirty plugin for Jekyll by Eli Naeher
#
# This plugin creates a site.years template variable which allow you to group archive links by year and month.
# The structure of site.years is:
# site.years = 2001=>[[post1, post2...], [...]], 2002=>[...]
#
# Usage should look something like this:
# {% for year in site.years %}
# <h2>Year {{ year.first.first.date | date: "%Y" }}</h2>
@Lax
Lax / README.md
Last active August 29, 2015 14:07 — forked from nikcub/README.md
anonymous
anonymous / config.json
Created March 3, 2015 09:20
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@jedi4ever
jedi4ever / gist:1376525
Created November 18, 2011 14:00
Ganglia - Gmond packet listener in Ruby - Proof of Concept
require 'socket'
require 'pp'
require 'xdr'
# Inspiration
# https://github.com/fastly/ganglia/blob/master/lib/gm_protocol.x
# https://github.com/igrigorik/gmetric/blob/master/lib/gmetric.rb
# https://github.com/ganglia/monitor-core/blob/master/gmond/gmond.c#L1211
# https://github.com/ganglia/ganglia_contrib/blob/master/gmetric-python/gmetric.py#L107
#include "mruby.h"
#include "mruby/proc.h"
#include "compile.h"
#include "mruby/dump.h"
#include <stdio.h>
#include <string.h>
void ruby_show_version(mrb_state *);
void ruby_show_copyright(mrb_state *);
void parser_dump(mrb_state*, struct mrb_ast_node*, int);
@hay
hay / WMStats.java
Last active August 30, 2016 11:03
Wikipedia statistics parser comparison
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WMStats {
private static final String FILE_NAME = "pagecounts-20141029-230000";
@seanlilmateus
seanlilmateus / gist:4134454
Last active January 12, 2018 16:11
Rubymotion GCD Future; with lazy evaluation
#!/usr/bin/env macruby -wKU
framework 'Foundation'
module Dispatch
module Futuristic
def proxy
Class.new(BasicObject) do
def initialize(obj)
@obj = obj
end
@alloy
alloy / 1-README.md
Created July 5, 2012 16:01
RubyMotion MacBacon UI layer spec.
@frankrausch
frankrausch / CustomDocumentWindow.swift
Last active September 4, 2018 06:43
Prevent NSPopover from stealing an NSTextField’s focus when using the popover to display live search results. Swift adaption of Wil Shipley’s solution (https://stackoverflow.com/a/21111462)
protocol PopoverFirstResponderStealingSuppression {
var suppressFirstResponderWhenPopoverShows: Bool { get }
}
class CustomDocumentWindow: NSWindow {
override func makeFirstResponder(_ responder: NSResponder?) -> Bool {
if responder != self.firstResponder,
let newFirstResponder = responder as? NSView {
let newFirstResponderWindow = newFirstResponder.window
@rishigesh
rishigesh / gist:fc66a2cb35372b2aa011a7a69f606d40
Created March 17, 2017 15:24
NSImage Flip Horizontally (Swift)
public func flipHorizontally() -> IOSXImage {
let existingImage: NSImage? = self
let existingSize: NSSize? = existingImage?.size
let newSize: NSSize? = NSMakeSize((existingSize?.width)!, (existingSize?.height)!)
let flipedImage = NSImage(size: newSize!)
flipedImage.lockFocus()
let t = NSAffineTransform.init()
t.translateX(by: (existingSize?.width)!, yBy: 0.0)