Skip to content

Instantly share code, notes, and snippets.

@ahnan4arch
ahnan4arch / rename
Created November 4, 2017 10:59 — forked from zhasm/rename
rename files by using perl regex.
#!/usr/bin/perl -w
#
# This script was developed by Robin Barker ([email protected]),
# from Larry Wall's original script eg/rename from the perl source.
#
# This script is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# Larry(?)'s RCS header:
# RCSfile: rename,v Revision: 4.1 Date: 92/08/07 17:20:30
@ahnan4arch
ahnan4arch / install-pacaur.sh
Created October 19, 2017 05:03 — forked from hlissner/install-pacaur.sh
Install pacaur on Arch Linux
if ! command -v pacaur >/dev/null; then
tmp=$(mktemp -d)
function finish {
rm -rf "$tmp"
}
trap finish EXIT
pushd $tmp
for pkg in cower pacaur; do
curl -o PKGBUILD https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=$pkg && \
@ahnan4arch
ahnan4arch / dnsmasq-gfwlist.py
Created October 15, 2017 15:42 — forked from lanceliao/dnsmasq-gfwlist.py
将gfwlist转换成带ipset的dnsmasq规则,适用于OpenWrt智能上网
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re
@ahnan4arch
ahnan4arch / MicroSecResolutionClock.h
Created June 28, 2017 16:37 — forked from davidalbertonogueira/MicroSecResolutionClock.h
std::chrono::system_clock with microseconds duration
// @brief Created on top of std::chrono::system_clock,
// MicroSecResolutionClock offers a clock with microseconds duration.
struct MicroSecResolutionClock : public std::chrono::system_clock {
typedef std::chrono::microseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef std::chrono::time_point<MicroSecResolutionClock, duration> time_point;
static const bool is_steady = false;
static const int ticks_per_time_t = period::den;
/*
example of c equivalent to php
<?php
// Create the keypair
$res=openssl_pkey_new();
// Get private key
openssl_pkey_export($res, $privkey);
// Get public key
@ahnan4arch
ahnan4arch / Base64.md
Created June 7, 2017 11:50 — forked from barrysteyn/Base64.md
OpenSSL Base64 En/Decode: Portable and binary safe.

OpenSSL Base64 Encoding: Binary Safe and Portable

Herewith is an example of encoding to and from base64 using OpenSSL's C library. Code presented here is both binary safe, and portable (i.e. it should work on any Posix compliant system e.g. FreeBSD and Linux).

License

The MIT License (MIT)

Copyright (c) 2013 Barry Steyn

@ahnan4arch
ahnan4arch / Container.scala
Created May 27, 2017 11:45 — forked from undetected1/Container.scala
Higher-Kinded types test
package com.sample.higher_kinded
trait Container[M[_]] {
def put[A](x: A): M[A]
def get[A](m: M[A]): A
}
@ahnan4arch
ahnan4arch / postsql.sql
Created May 27, 2017 11:43 — forked from undetected1/postsql.sql
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- JSON Types need to be mapped into corresponding PG types
--
-- Number => INT or DOUBLE PRECISION
-- String => TEXT
@ahnan4arch
ahnan4arch / ByteReader.cpp
Created May 20, 2017 09:34 — forked from dtalley/ByteReader.cpp
Small C++ utility for reading binary data from a byte array
#include "ByteReader.h"
using namespace Orionark::Utility;
ByteReader::ByteReader(char *data)
: data(data),
pointer(0)
{
if( O32_HOST_ORDER == O32_LITTLE_ENDIAN )
{
@ahnan4arch
ahnan4arch / build.gradle
Created May 15, 2017 08:04 — forked from ph0b/build.gradle
gradle configuration for a module depending on a prebuilt native library - using gradle-experimental:0.6.0+ plugin.
apply plugin: 'com.android.model.library'
model {
repositories {
libs(PrebuiltLibraries) {
mydependency {
headers.srcDir "src/main/jni/prebuilts/include"
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("src/main/jni/prebuilts/${targetPlatform.getName()}/libmydependency.so")