Skip to content

Instantly share code, notes, and snippets.

View caglartoklu's full-sized avatar

Çağlar Toklu caglartoklu

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / pip_upgrade_all.py
Last active July 2, 2019 16:05
upgrade all #python packages using #pip
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Traverses all the Python packages and upgrades them.
"""
from __future__ import print_function
from __future__ import unicode_literals
@caglartoklu
caglartoklu / check_on_windows.vim
Created July 14, 2017 06:47
check if on windows on vim #vim
if has("win16") || has("win32") || has("win64")
else
endif
@caglartoklu
caglartoklu / source_file_if_exists.vim
Last active July 14, 2017 06:51
source a file if exists in VimL #vim
try
source $HOME/_vimrc_local
catch /^Vim\%((\a\+)\)\=:E484/
endtry
@caglartoklu
caglartoklu / Vagrantfile
Last active July 12, 2019 14:17
Vagrantfile for development on Ubuntu with vim, Python, Node.js(npm, angular-cli, yarn), Docker
# -*- mode: ruby -*-
# vi: set ft=ruby :
# #############################
# R E A D M E
#
#
# # Requirements
#