Skip to content

Instantly share code, notes, and snippets.

@venj
venj / trans_gif.sh
Created November 1, 2016 03:59
convert video to gif
#!/bin/sh
# Convert video to gif.
if [[ $# -ne 3 ]]; then
echo "Usage: trans_gif source.mp4 target.gif 300"
exit 1
fi
palette="/tmp/palette.png"
filters="fps=15,scale=$3:-1:flags=lanczos"
@venj
venj / jlpt_slack.rb
Created August 18, 2016 03:53
JLPT notifier
#!/usr/bin/ruby
exit(0) if File.exists?('/root/.jlpt_sent')
require 'net/https'
require 'json'
require 'open-uri'
require 'hpricot'
SLACK_URL = "https://hooks.slack.com/services/xxxxx"
Incident Identifier: 2D2808D0-F71F-4C68-AFDD-639175C4239E
CrashReporter Key: 153f5645627079591a0e528446a69296c17f523e
Hardware Model: iPhone7,1
Process: SwiftyGohan [2132]
Path: /private/var/containers/Bundle/Application/B8888313-A544-4101-8868-62BE35A49A4E/SwiftyGohan.app/SwiftyGohan
Identifier: me.imach.SwiftyGohan
Version: 596 (2.2)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
@venj
venj / mavericks_bootable_iso.sh
Created July 12, 2016 12:38
Create Bootable ISO from Mavericks App.
#!/usr/bin/env bash
# Original: http://thezinx.com/2013/10/29/create-bootable-dmg-iso-mavericks-app.html
V_BUILD=/Volumes/install_build
V_APP=/Volumes/install_app
T_SI_B=/tmp/mavericks
T_SI=$T_SI_B.sparseimage
@venj
venj / ipv6-regex-test.sh
Created April 29, 2016 00:29 — forked from syzdek/ipv6-regex-test.sh
Simple script to test my IPv6 regular expression.
#!/bin/sh
#
# Use posixregex CLI tool from: https://github.com/syzdek/dmstools/blob/master/src/posixregex.c
RE_IPV4="((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
posixregex -r "^(${RE_IPV4})$" \
127.0.0.1 \
10.0.0.1 \
192.168.1.1 \
//: Playground - noun: a place where people can play
import Foundation
import Darwin
let regex = UnsafeMutablePointer<regex_t>.alloc(1)
let regexString = "^[[:alnum:]]+$"
let regex_str = regexString.cStringUsingEncoding(NSUTF8StringEncoding)!
if (regcomp(regex, regex_str, REG_ICASE | REG_EXTENDED) != 0) {
@venj
venj / test.c
Created December 22, 2015 08:51
#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
#include <unicode/uregex.h>
int main(int argc, char const *argv[])
{
regex_t regex;
if (regcomp(&regex, "\\w+", REG_ICASE | REG_EXTENDED)) {
printf("Error compile\n");
@venj
venj / tl.rb
Created December 22, 2015 08:48
#!/usr/bin/env ruby
require 'twitter'
require 'open-uri'
require 'open_uri_redirections'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "riOPILJqG0AtzB8x7hiqRA"
config.consumer_secret = "uBlaPxB3QONvCyvvq78CY9UjpHYdxYdeEb0d1QAaU"
config.access_token = "191735866-EHC4Xbf5O6fSu62CI72Hk1PPQ6d0Jn81sMWkWF9p"
#!/usr/bin/env ruby
require 'fileutils'
require 'shellwords'
include FileUtils
#hdiutil makehybrid -iso -joliet -o image.iso /path/to/source
ARGV.each do |rootdir|
cd rootdir do
Dir["*"].each do |subdir|
destination = "/Volumes/WD3T/ISOs/#{rootdir.shellescape}/"
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
BAD_FILES = ['@eaDir', 'Thumbs.db']
def transverse(dir)
cd dir do
Dir["*"].each do |d|