Skip to content

Instantly share code, notes, and snippets.

View ba0f3's full-sized avatar
🇻🇳
#VietnamLeavesNoOneBehind

Huy Doan ba0f3

🇻🇳
#VietnamLeavesNoOneBehind
View GitHub Profile
@penk
penk / ubuntu_ui_toolkit_for_mac_osx.patch
Created June 3, 2013 22:23
Ported Ubuntu Components to Mac OSX and Qt 5.0.2
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2013-05-21 11:06:55 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-06-03 21:51:32 +0000
@@ -18,7 +18,7 @@
#include <QtQml>
#include <QtQuick/private/qquickimagebase_p.h>
-#include <QDBusConnection>
+//#include <QDBusConnection>
#include <QtGui/QGuiApplication>
@coder4web
coder4web / redis_install_centos.txt
Last active September 10, 2017 01:45
Redis install on CentOS 6.4
BTW yum has last Redis too, remi repository at least.
$ sudo -i
$ yum list redis
$ redis.x86_64 2.6.13-1.el6.remi remi
But today we want compile redis from source (see http://redis.io/download)
$ yum install make gcc tcl
$ cd /usr/local/src
@victorreyesh
victorreyesh / Aircrack Commands
Created September 12, 2013 03:36
Cracking WPA2 / WEP Wifi / Aircrack 10 seconds guide. For Mac OSX
//Install Macports.
//Install aircrack-ng:
sudo port install aircrack-ng
//Install the latest Xcode, with the Command Line Tools.
//Create the following symlink:
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
//Figure out which channel you need to sniff:
sudo airport -s
sudo airport en1 sniff [CHANNEL]
@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@ccbrown
ccbrown / DumpHex.c
Last active February 12, 2025 00:25
Compact C Hex Dump Function w/ASCII
#include <stdio.h>
void DumpHex(const void* data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i) {
printf("%02X ", ((unsigned char*)data)[i]);
if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') {
ascii[i % 16] = ((unsigned char*)data)[i];
@xingrz
xingrz / RealmAdapter.java
Last active May 22, 2020 19:46
A RecyclerView.Adapter-like Adapter that binds RealmResults to ListView
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import io.realm.RealmObject;
import io.realm.RealmResults;
public abstract class RealmAdapter<E extends RealmObject, VH extends RealmAdapter.ViewHolder>
extends BaseAdapter {
@shiva
shiva / FindNim.cmake
Created October 21, 2014 12:47
cmake module for running nimrod compiler
include(CMakeParseArguments)
find_program(NIM_EXECUTABLE nimrod PATHS ENV PATH)
mark_as_advanced(NIM_EXECUTABLE)
# Determine the valac version
if(NIM_EXECUTABLE)
execute_process(COMMAND ${NIM_EXECUTABLE} "--version"
OUTPUT_VARIABLE NIM_VERSION
@jice
jice / strongswan ubu 14.04
Created November 5, 2014 00:44
Build latest Strongswan (with libipsec, DNSSEC support, ...) on Ubuntu 14.04
0. After a fresh install
# aptitude update && aptitude full-upgrade && reboot
1. Install necessary packages for building Strongswan (may vary depending on your configure options, configure script will tell you)
# aptitude install build-essential libgmp-dev libunbound-dev libldns-dev
2. Get, check, and unpack the sources
@PiBa-NL
PiBa-NL / haproxy, sending the source ip to the webserver.
Created December 21, 2014 23:24
haproxy, sending the source ip to the webserver.
To send the ip addres of the client/webbrowser to the server/webserver behind it there are a few options:
1- option forwardfor
2- send-proxy
3- source 0.0.0.0 usesrc clientip
1- option forwardfor
This is an easy option to configure in haproxy, it does require that http layer7 processing is used 'mode http' and the webserver/ webapplication that wants to log or use the ip of the client must use the http-header 'X-Forwarded-For' to read the clientip.
2- send-proxy / send-proxy-v2 / send-proxy-*
This is can be used both with mode tcp and http, it does however require that the server also understands the proxyprotocol. Some applications have added support for this protocol which adds a few bytes with ip information before the actual request.
@mcnewton
mcnewton / example.out
Last active November 14, 2023 19:25
hex dump C buffer
example with linelen=16, split=8
30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 01234567 89ABCDEF
61 62 63 64 65 66 30 31 32 33 34 35 36 37 38 39 abcdef01 23456789
41 41 41 41 42 42 42 42 43 43 43 43 44 44 44 44 AAAABBBB CCCCDDDD
48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 54 65 73 74 Hello Wo rld.Test
2d 6c 69 6e 65 0a -line.
example with linelen=16, split=4
30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 0123 4567 89AB CDEF
61 62 63 64 65 66 30 31 32 33 34 35 36 37 38 39 abcd ef01 2345 6789