Skip to content

Instantly share code, notes, and snippets.

@Jiezhi
Jiezhi / ndk_c_call_java_method
Created May 28, 2015 08:25
how c/c++ call java method in android by jni
#include "com_jiezhi_jnitest_MainActivity.h"
jclass mClass;
jobject mObject;
jmethodID mStaticmethodID, mnotStaticMethodID;
/*
* Class: com_jiezhi_jnitest_MainActivity
* Method: nativeInit
* Signature: ()V
@havvg
havvg / Firewall.js
Last active April 15, 2025 23:12
ExtJS 6: JSON Web Token API Login with Promises
Ext.define('App.security.Firewall', {
singleton: true,
requires: [
'App.security.TokenStorage'
],
isLoggedIn: function() {
return null !== App.security.TokenStorage.retrieve();
},
1. install openjdk
`sudo apt-get install openjdk-7-jdk`
2. install `android sdk`
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
@Dan1el42
Dan1el42 / gist:e0bc84883902e0fb4fbf8a5bf8dfcdd7
Created September 1, 2016 07:37
PowerShell: Disable SSL certificate validation
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
@george-hawkins
george-hawkins / arm64.md
Last active December 5, 2024 08:41
Running virtualized x86_64 and emulated arm64 Ubuntu cloud images using QEMU

QEMU arm64 cloud server emulation

This is basically a rehash of an original post on CNXSoft - all credit (particularly for the Virtio device arguments used below) belongs to the author of that piece.

Download the latest uefi1.img image. E.g. ubuntu-16.04-server-cloudimg-arm64-uefi1.img from https://cloud-images.ubuntu.com/releases/16.04/release/

Download the UEFI firmware image QEMU_EFI.fd from https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/

Determine your current username and get your current ssh public key:

@HintikkaKimmo
HintikkaKimmo / who_data.py
Created February 21, 2017 06:10
handy way to read csv files with unknown csv dialect
import csv
import pprint
# opens csv file and assingns it to an object
with open('data-text.csv') as csvfile:
# Use Sniffer to figure out csv dialect
dialect = csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
# pass the dialect to filereader to read the file
reader = csv.reader(csvfile, dialect)
@keithweaver
keithweaver / get-file.py
Last active October 8, 2021 11:56
Get File Content with Python
# Example of getting file content
def getFileContent(pathAndFileName):
with open(pathAndFileName, 'r') as theFile:
# Return a list of lines (strings)
# data = theFile.read().split('\n')
# Return as string without line breaks
# data = theFile.read().replace('\n', '')
@cschiewek
cschiewek / x11_docker_mac.md
Last active March 25, 2025 13:23
X11 in docker on macOS

To forward X11 from inside a docker container to a host running macOS

  1. Install XQuartz: https://www.xquartz.org/
  2. Launch XQuartz. Under the XQuartz menu, select Preferences
  3. Go to the security tab and ensure "Allow connections from network clients" is checked.
  4. Run xhost + ${hostname} to allow connections to the macOS host *
  5. Setup a HOSTNAME env var export HOSTNAME=`hostname`*
  6. Add the following to your docker-compose:
 environment:
@sameerkumar18
sameerkumar18 / example_flask_googlecaptcha.py
Created May 20, 2017 07:04
A Simple Python Flask Example for Google Recaptcha (implemented on http://ipusearch.herokuapp.com)
RECAPTCHA_PUBLIC_KEY = '<public key>'
RECAPTCHA_PRIVATE_KEY = '<private key>'
def checkRecaptcha(response, secretkey):
url = 'https://www.google.com/recaptcha/api/siteverify?'
url = url + 'secret=' + str(secretkey)
url = url + '&response=' +str(response)
@ljjjustin
ljjjustin / socat-tcp-to-unix-socket.sh
Last active April 1, 2025 15:17
socat-unix-socket-to-tcp.sh
#!/bin/bash
if [ $# -ne 3 ]; then
echo "usage: $0 <unix socket file> <host> <listen port>"
exit
fi
SOCK=$1
HOST=$2
PORT=$3