Skip to content

Instantly share code, notes, and snippets.

View figengungor's full-sized avatar

Figen Güngör figengungor

View GitHub Profile
/*
* Copyright 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
@figengungor
figengungor / sharedmemory.c
Created October 24, 2013 15:16
Shared Memory in C (Linux)
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<sys/shm.h>
int main()
{
char* shared_memory;
int segment_id;
@figengungor
figengungor / heap.py
Created October 9, 2013 19:14
Usage of heapq module in Python
from __future__ import print_function
from heapq import *
heapC=[4,5,1,3]
print("our candidate random array who volunteered to be a heap array:\n")
print(heapC,"\n")
heapify(heapC)
print("after sorting our candidate as heap: \n")
print(heapC,"\n")
@figengungor
figengungor / child.c
Created October 8, 2013 18:14
Child Process in Windows Lab 2 -- creates threads
#include<stdio.h>
#include<Windows.h>
#include<stdlib.h> //required for malloc
#include<malloc.h> //required for malloc
//thread needs a function to execute, a parameter to this function if it has any, and a thread id
DWORD WINAPI threadwork(LPVOID param);
//DWORD is a data type for OS like int, WINAPI for OS to understand that it is a thread function
//Thread function only takes one parameter.
@figengungor
figengungor / parent.c
Created October 8, 2013 15:39
Parent Process in Windows Lab 2 -- creates a process that creates threads
#include <stdio.h>
#include <Windows.h>
define NO_OF_PROCESS=1;
int main(int argc, char* argv[])
{
STARTUPINFO si[NO_OF_PROCESS];
PROCESS_INFORMATION pi[NO_OF_PROCESS];
HANDLE handles[NO_OF_PROCESS];
@figengungor
figengungor / parent.c
Created October 7, 2013 21:07
Parent Process in Windows Lab1
#include<stdio.h>
#include<Windows.h>
#define NO_OF_PROCESS 4
int main(int argc, char* argv[])
{
STARTUPINFO si[NO_OF_PROCESS]; //needed info to create process, cb(size needed for info), new window, title...
PROCESS_INFORMATION pi[NO_OF_PROCESS]; //to store info of newly created process, ids, handles of process and thread...
int i=0;
@figengungor
figengungor / child.c
Last active December 24, 2015 22:38
Child Process in Windows Lab1
#include<stdio.h>
#include<Windows.h>
int main(int argc, char* argv[])
{
//we'll execute this child process with one argument from parent process,
//so we are checking if the number of arguments is right.
//If you wanna give more arguments, check according to this.
//argc is the number of arguments + 1(process that is executed)
// ex: child.exe 1 => argc=2 , calculator.exe "what's up?" "hey" "yov" 4 => argc=5
@figengungor
figengungor / pointer.c
Last active December 24, 2015 18:59
Pointer
#include<stdio.h> //for printf
#include<stdlib.h> //for system("pause")
int main(int argc, char* argv[])
{
int ages[] = {30, 28, 31, 35};
char *names[] = {"Dexter", "Debra", "Hannah", "Masuka"};
int count = sizeof(ages)/sizeof(int);
//setup pointers