Skip to content

Instantly share code, notes, and snippets.

View bzdgn's full-sized avatar
🏠
Working from home

Levent Divilioglu bzdgn

🏠
Working from home
View GitHub Profile
@bzdgn
bzdgn / MemcachedClient.py
Last active August 29, 2015 14:23
Python Memcached Client Script
#!/user/bin/env python
import os
from time import sleep
import subprocess
import memcache
mclient = memcache.Client(['127.0.0.1:11211'], debug=0)
try:
@bzdgn
bzdgn / MemcachedServer.py
Created June 17, 2015 20:20
Python Memcached Server Script
#!/user/bin/env python
import os
from time import sleep
import subprocess
import memcache
mclient = memcache.Client(['127.0.0.1:11211'], debug=0)
user = mclient.get("user")
@bzdgn
bzdgn / TestSleepMethod.java
Last active August 29, 2015 14:23
A Checked Sleep Method versus Thread.sleep() Method for Consistency
package com.levent.experimental.sleep;
/*
* Because that the consistency of the precision of Thread.sleep method
* is not guaranteed, a container method (delayNSeconds) is tested if
* the duration reached with the Thread.sleep method or not.
*
* On this simple dummy code, Thread.sleep method is compared with the
* container method for countTest times.
*
@bzdgn
bzdgn / TestSleepMethodEnhanced.java
Last active August 29, 2015 14:23
A Checked Sleep Method versus Thread.sleep() Method for Consistency - Enhanced Version
package com.levent.experimental.sleep;
/*
* Because that the consistency of the precision of Thread.sleep method
* is not guaranteed, a container method (delayNSeconds) is tested if
* the duration reached with the Thread.sleep method or not.
*
* On this simple dummy code, Thread.sleep method is compared with the
* container method for countTest times.
*
@bzdgn
bzdgn / primeTestWhile.cpp
Last active October 29, 2015 00:42
Prime Test Using While
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Enter a number" << endl;
cin >> x;
@bzdgn
bzdgn / primeTestFor.cpp
Created October 29, 2015 00:41
Prime Test Using For
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Enter a number" << endl;
cin >> x;
bool prime = true;
@bzdgn
bzdgn / GenericInstanceTest.java
Last active October 30, 2015 20:10
Java Generic Instance Test
// Demonstraction on the wikipedia article sample code, actual source;
// https://en.wikipedia.org/wiki/Generics_in_Java#Problems_with_type_erasure
package com.levent.typeerasure;
import java.util.ArrayList;
public class GenericInstanceTest {
public static void main(String[] args) {
ArrayList<Integer> li = new ArrayList<Integer>();
@bzdgn
bzdgn / LinkedList.cpp
Last active November 1, 2015 00:23
Linked List Sample in C++
#include <iostream>
#include <string>
using namespace std;
class Employee
{
private:
friend class EmployeeList;
string name;
int age;
@bzdgn
bzdgn / ConstPointer.cpp
Last active November 3, 2015 11:10
Const Pointer Demo and Notes
// Const.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
class Person
{
private:
@bzdgn
bzdgn / PointerSample.c
Last active November 9, 2015 15:11
C Pointer Sample
#include <stdio.h>
int main()
{
/* a simple integer */
int i = 1234;
/* a pointer to an integer */
int * p = 0;
p = &i;