Skip to content

Instantly share code, notes, and snippets.

@honux77
honux77 / qsort.c
Created October 24, 2014 05:01
qsort example
#include <stdlib.h>
#include <stdio.h>
int compare(const void *x, const void * y) {
int ix = *(int*)x;
int iy = *(int*)y;
return ix - iy;
}
int main(void) {
@honux77
honux77 / ptrex.c
Created October 24, 2014 05:23
various pointer
#include <stdlib.h>
#include <stdio.h>
int foo(int x) { return 1; }
int main(void) {
int *ptr[2];
int (*ptr2)[2];
int(*ptr3)(int);
int x = 10;
int arr[] = { 1, 2, 3, 4};
@honux77
honux77 / dict_object.js
Created November 15, 2014 01:39
object dictionary
var friends = {};
friends.bill = {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']
};
friends.steve = {
firstName: "Steve",
lastName: "Jobs",
@honux77
honux77 / Tran.java
Created December 11, 2014 08:31
jdbc transaction example
import java.sql.*;
public class Tran {
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver");
String host = "jdbc:mysql://192.168.56.102/popidb";
String user = "popi";
String pw = "db1004";
Connection conn = DriverManager.getConnection(host, user, pw);
conn.setAutoCommit(false);
@honux77
honux77 / mysin.py
Last active August 29, 2015 14:14
math sine implementation
import math
def fact(x):
if x == 1:
return 1
else:
return x * fact(x-1);
def mysin(x):
return x - math.pow(x,3)/fact(3) + pow(x,5)/fact(5) - pow(x,7)/fact(7) \
+ math.pow(x,9)/fact(9)
@honux77
honux77 / test.c
Created February 6, 2015 02:23
undefined action for c
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int *p = malloc(sizeof(int));
int *q = realloc(p, sizeof(int));
int *z = realloc(q, sizeof(int));
*p = 1;
*q = 2;
*z = 3;

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@honux77
honux77 / tensline.sh
Created April 8, 2015 01:29
Tenth Line
# Read from the file file.txt and output the tenth line to stdout.
for i in $(seq 1 10)
do
read line
done < "file.txt"
echo $line
@honux77
honux77 / ten2.sh
Created April 8, 2015 02:07
Tenth Line2
sed -n '10p' file.txt
aws s3api list-objects --bucket %bucketname% --query 'sum(Contents[].Size)' --output json | awk 'BEGIN {total=0}{total+=$0}END{print total/1024/1024/1024" GB"}'