Skip to content

Instantly share code, notes, and snippets.

View junxie6's full-sized avatar
🐢
Push the limits of what's possible. Today.

Jun Hsieh junxie6

🐢
Push the limits of what's possible. Today.
View GitHub Profile
@aembleton
aembleton / Ignore certificate for HttpURLConnection in Android.java
Created March 27, 2011 17:25
The following code disables SSL certificate checking for any new instances of HttpsUrlConnection
/**
* Disables the SSL certificate checking for new instances of {@link HttpsURLConnection} This has been created to
* aid testing on a local box, not for use on production.
*/
private static void disableSSLCertificateChecking() {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@FurryHead
FurryHead / array.c
Created July 15, 2011 18:55
Dynamic array and map in C.
#include <string.h>
#include <stdlib.h>
#include "array.h"
typedef struct array array;
typedef struct map map;
/** @brief Allocates and initializes a new array */
array *array_new(void) {
array *tmp = malloc(sizeof(array));
@henrik242
henrik242 / DisableCertificateValidation.java
Created December 22, 2011 12:37
Disable validation of SSL certificates in Java
public static void disableCertificateValidation() {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}};
@nsuan
nsuan / announce.php
Created March 3, 2012 16:57
Bitstorm Tracker
<?php
/*
* Bitstorm - A small and fast Bittorrent tracker
* Copyright 2008 Peter Caprioli
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@lpereira
lpereira / coro.c
Created March 22, 2012 01:12
Simple coroutine implementation in C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
typedef struct coro_t_ coro_t;
typedef struct thread_t_ thread_t;
typedef int (*coro_function_t)(coro_t *coro);
typedef enum {
CORO_NEW,
@vys
vys / net-test.go
Created October 2, 2012 18:55
A simple client and server with lots of connections in GO. Testing GO's network connection handling.
package main
import (
"flag"
// "fmt"
"github.com/vys/go-humanize"
"io"
"log"
"net"
//"net/http"
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
@matugm
matugm / array.c
Last active May 11, 2021 04:30
dynamic arrays in c
#include "array.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
struct ArrayData *initArray() {
struct ArrayData *newArray = malloc(sizeof(struct ArrayData));
newArray->pointer = calloc(1000, sizeof(int));
newArray->size = 1000;
@artyom
artyom / rpc-tls-client.go
Last active October 9, 2023 15:44
Go RPC over TLS.You have to create the following keys: certs/client.crt, certs/client.key, certs/server.crt, certs/server.key. client.crt and server.crt should be signed with ca.crt, which should be concatenated to both client.crt and server.crt. It's easier to do with easy-rsa: http://openvpn.net/index.php/open-source/documentation/howto.html#pki
package main
import (
"crypto/tls"
"crypto/x509"
"log"
"net/rpc"
)
func main() {