Skip to content

Instantly share code, notes, and snippets.

@nomadalex
nomadalex / install-rbenv.sh
Created December 27, 2017 08:18
install rbenv on centos 7
#!/bin/bash
prog=${0##*/}
function usage ()
{
cat << EOF
NAME
$prog - Install rbenv.
@nomadalex
nomadalex / TrafficLightAttribute.cs
Created August 2, 2017 08:50 — forked from LotteMakesStuff/TrafficLightAttribute.cs
TrafficLight control/layout/property drawer: Adds a new editor control that draws lil Traffic Lights in the inspector. its really useful for visualizing state. For example, checkboxes can be hard to read at a glace, but a Red or Green status light is easy! Recommend you use the attached package, as it has all the icon image files.
// Non Editor code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class TrafficLightAttribute : PropertyAttribute
{
public bool DrawLabel = true;
public string CustomLabel;
public bool AlsoDrawDefault;
@nomadalex
nomadalex / create_config_iso.sh
Created June 7, 2017 12:32
cloud-init config creator
# Bridge for VMs (default on Fedora is virbr0)
BRIDGE=virbr0
# Cloud init files
USER_DATA=user-data
META_DATA=meta-data
CI_ISO=$1-cidata.iso
# cloud-init config: set hostname, remove cloud-init package,
# and add ssh-key
@nomadalex
nomadalex / centos7-afp.sh
Created March 3, 2016 17:43
Install Time Machine and Samba service on CentOS 7
#!/bin/bash
# Install Time Machine service on CentOS 7
# http://netatalk.sourceforge.net/wiki/index.php/Netatalk_3.1.7_SRPM_for_Fedora_and_CentOS
# http://confoundedtech.blogspot.com/2011/07/draft-draft-ubuntu-as-apple-time.html
# https://zitseng.com/archives/6182
# https://gist.github.com/darcyliu/f3db52d6d60ef4f4f4ef
sudo yum install -y avahi-devel bison cracklib-devel dbus-devel dbus-glib-devel docbook-style-xsl flex libacl-devel libattr-devel libdb-devel libevent-devel libgcrypt-devel krb5-devel mysql-devel openldap-devel openssl-devel pam-devel quota-devel systemtap-sdt-devel tcp_wrappers-devel libtdb-devel tracker-devel
wget http://www003.upp.so-net.ne.jp/hat/files/netatalk-3.1.8-0.1.4.fc24.src.rpm
@nomadalex
nomadalex / bypy_syncup_cleanup.rb
Created November 25, 2015 10:48
clean uploaded file and dirs after bypy syncup
#!/usr/bin/env ruby
require "fileutils"
list_fn = ARGV[0]
root_dir = ARGV[1]
sames = []
is_same_files = false
const char hex_asc[] = "0123456789abcdef";
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
static inline char *hex_byte_pack(char *buf, u8 byte)
{
*buf++ = hex_asc_hi(byte);
*buf++ = hex_asc_lo(byte);
return buf;
}
@nomadalex
nomadalex / fix_torrent_encoding.rb
Created April 27, 2015 03:07
Fix torrent encoding, convert gbk to utf8, for fix file names.
#! /usr/bin/env ruby
# this script used to convert gbk encoding torrent to utf8 encoding
require "bencode"
def print_files(data)
files = data["info"]["files"]
files.each do |f|
path = f["path"][0]
@nomadalex
nomadalex / makeFace.js
Created May 10, 2012 01:25
颜字符生成器
var Face =
{
version : '1.0.0',
noInit : true,
face : ['(',')','[',']','|','|'],
eyes : [' ̄',' ̄','—','—','_','_','﹁','﹁','^','^','~','~','=','=','@','@','·','·','`','′','>','<','→','←','〒','〒','┬','┬','T','T','゜','゜','。','。','●','●','◎','◎','⊙','⊙','○','○','╯','╰','︶','︶','〃','〃','Φ','Φ','Θ','Θ','+','+','x','x','$','$','≥','≤','u','u','U','U','・ิ', '・ิ', '❛', '❛', '⊙', '⊙', ' ̄', ' ̄', '◕ˇ', 'ˇ◕'],
mouth : [
// mouth
@nomadalex
nomadalex / kinect-motor.cpp
Created April 24, 2012 03:28
kinect motor cotrol
// Usb control: http://openkinect.org/wiki/Protocol_Documentation#Control_Packet_Structure
#include <XnUSB.h>
#include <cstdio>
#include <cstring>
#ifdef _WIN32
#include <Windows.h>
void sleep_ (int s)
{
/*
12306 Auto Login => A javascript snippet to help you auto login 12306.com.
Copyright (C) 2011 Kevintop
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes 12306.user.js