Skip to content

Instantly share code, notes, and snippets.

View cengiz-io's full-sized avatar

Cengiz Can cengiz-io

View GitHub Profile
section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
@cengiz-io
cengiz-io / union.rs
Created August 18, 2014 12:46
Playing with Rust
#![feature(struct_variant)]
extern crate debug;
enum Direction {
Up, Down, Left, Right
}
/*
use std::fmt;
@cengiz-io
cengiz-io / gist:bb40f9e3139e329e3b7f
Last active August 29, 2015 14:07
What the heck is this?
#include <iostream>
struct bar {
int i;
};
struct foo {
int bar::* p;
};
#!/bin/bash
LOG="mail.log"
while read -r -a array; do
echo ${array[*]} >> ${LOG}
done
#include <iostream>
#include <memory>
#include <string>
class Greeter {
public:
template <class T>
Greeter(T data) : self_(std::make_shared<Model<T>>(data)) {}
void greet(const std::string &name) const {
@cengiz-io
cengiz-io / lowercase.cpp
Last active August 29, 2015 14:07
codeeval challange 20
#ifndef __APPLE__
#include <algorithm>
#endif
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
@cengiz-io
cengiz-io / init.cpp
Created October 28, 2014 21:27
copy initialization and direct initialization
#include <iostream>
using namespace std;
class A {
public:
A() {
cout << "default constructor" << endl;
}
A(const A& x) {
@cengiz-io
cengiz-io / MinStack.cpp
Created November 10, 2014 21:47
Stack implementation which returns MIN() value in O(1) time (LeetCode OJ)
#include <stack>
class MinStack {
public:
void push(int x) {
s.push(x);
if (m.empty() == true || m.top() >= x) {
m.push(x);
}
import ctypes
class IntStruct(ctypes.Structure):
_fields_ = [("ob_refcnt", ctypes.c_long),
("ob_type", ctypes.c_void_p),
("ob_size", ctypes.c_ulong),
("ob_digit", ctypes.c_long)]
def __repr__(self):
return ("IntStruct(ob_digit={self.ob_digit}, "
"refcount={self.ob_refcnt})").format(self=self)
int main() {
int *x[10];
int (*y)[10];
int val = 666;
for (int a = 0; a < 10; a++) {
x[a] = &val;
(*y)[a] = val;
}