Skip to content

Instantly share code, notes, and snippets.

@markson
markson / getpid.c
Created August 6, 2012 02:37
Test the getpid() function
#include <stdio.h>
#include <sys/types.h>
int main(void){
pid_t this_process;
this_process = getpid();
printf("this process value is %d and hex value if 0x%x\n", this_process,this_process);
}
@markson
markson / a.rb
Created September 15, 2012 03:34
this is the test of jist
$ jist a.rb
https://gist.github.com/0d07bc98c139810a4075
By default it reads from STDIN, and you can set a filename with -f.
$ jist -f test.rb <a.rb
https://gist.github.com/7db51bb5f4f35c480fc8
Alternatively, you can just paste from the clipboard:
$ jist -P
https://gist.github.com/6a330a11a0db8e52a6ee
@markson
markson / chest game
Created October 15, 2012 07:00
Chest game public
import ipdb
import re
import sys
PROMPT_SIZE = "Board size: "
ERROR_SIZE = "Size must be an odd number between 5 and 9"
PROMPT_MOVE_X = "Player X, enter move: " # Or player Y ...
PROMPT_MOVE_Y = "Player Y, enter move: " # Or player Y ...
ERROR_MOVE_LENGTH = "Move must be 5 characters"
ERROR_MOVE_PIECE ="Error move piece" # e.g player X can not move piece "Y" or piece that was used by the opponent in his/her last move.
ERROR_MOVE_POSITION = "Invalid position" # you can't place your player on occupied position, or place S on "T", or go over the board
@markson
markson / javascript-object.js
Created November 18, 2012 00:25
javascript object creation
var m = {
name:'Markson',
gender:'Male',
laugh:function(){
return "hahaha";
}
}
console.log(m.name);
console.log(m.laugh());
@markson
markson / ruby-class-property
Created November 20, 2012 01:16
Ruby Class with property
[28] pry(main)> class Users
[28] pry(main)* attr_accessor :id, :first_name, :last_name
[28] pry(main)* end
// Print the name and value of each property of o. Return undefined. function printprops(o) {
for(var p in o)
console.log(p + ": " + o[p] + "\n");
}
function say(a){
console.log(a)
if(a < 5)
say(a + 1)
}
say(1)
function foo(){
x = 3
};
foo();//referenceError
public class HelloMarkson {
public static void main(String[] args) {
String str = new java.lang.String("Hello Markson");
System.out.println(str);
}
}
require 'pry'
class Animal
def initialize(name)
@name = name
end
def say()
begin
raise NotImplementedError, "something goes wrong"
rescue Exception
puts $!