Skip to content

Instantly share code, notes, and snippets.

View caglartoklu's full-sized avatar

Çağlar Toklu caglartoklu

View GitHub Profile
@caglartoklu
caglartoklu / single_function_logging.py
Created November 22, 2015 15:55
Single function #logging #python
def get_logger():
"""
Returns a logger object that can directly be used.
It is a single function singleton,
it returns the same object each time it is called.
Do not forget to change:
logger_name = "defaultlogger"
logger_file_path = "log1.log"
@caglartoklu
caglartoklu / custom_exception_class.cs
Created July 19, 2015 11:04
Custom Exception Class #cs #exception
namespace SomeNamespace
{
using System;
class CustomException : Exception
{
public CustomException()
: base() { }
public CustomException(string message)
@caglartoklu
caglartoklu / string_interpolation.cs
Last active August 29, 2015 14:25
C# String Interpolation #cs #string
using System;
public class Program
{
public static void Main()
{
// simple string interpolation
string someString = @"
Do you have a {0} {1} ?
";
@caglartoklu
caglartoklu / list_concatenation.cs
Last active August 29, 2015 14:25
C# List Concatenation #cs #list
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<string> listed = new List<string>() {"1", "2", "3", "4"};
Console.WriteLine(">" + string.Join("-", listed));
// >1-2-3-4
@caglartoklu
caglartoklu / python_template1.py
Last active March 11, 2021 12:44
Python Template 1 #python #template
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
TODO:doc here
"""
def main():
"""
@caglartoklu
caglartoklu / datetimestamp.py
Created February 25, 2013 12:56
Returns string representation of datetime objects. #python #datetime
import datetime
def get_datetimestamp(sep_date="", sep_group="_", sep_time="", moment=None):
"""
Returns string representation of datetime objects.
By default, the value will look like "20121212_120102" and it
is safe to use it on file names.
@caglartoklu
caglartoklu / .bash_profile
Created February 18, 2013 10:25
.bash_profile configuration for Python 2.6, cx_Oracle 5.1.2, Oracle Client 11.2.0 on RHEL 6.3 #bash #oracle #shell
# save this file as .bash_profile, or merge with the existing one.
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
# Red Hat Enterprise Linux Server release 6.3, x84_64
# Oracle Client 11.2.0 (not Instant Client)
# Python 2.6
@caglartoklu
caglartoklu / simplehttpserver.sh
Created February 17, 2013 10:54
Simple HTTP Server in Python >= 2.4. #python #http #server
python -m SimpleHTTPServer 8090
@caglartoklu
caglartoklu / app.config
Last active December 13, 2015 18:19
Simple app.config usage in C#. #cs #config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="one" value="1"/>
<add key="two" value="2"/>
<add key="three" value="3"/>
<add key="four" value="4"/>
@caglartoklu
caglartoklu / install_dosbox.sh
Last active February 15, 2024 21:26
Installing and Configuring DOSBox on Ubuntu #dosbox #ubuntu
# DOSBox is a great emulator to run old DOS games
# and applications.
# This configuration has been tested on Ubuntu 11.04 with DOSBox 0.74
# but# it should work on other distros too.
# This code snippet runs on a fresh install of DOSBox
# since it appends lines to DOSBox configuration file.