Skip to content

Instantly share code, notes, and snippets.

View caglartoklu's full-sized avatar

Çağlar Toklu caglartoklu

View GitHub Profile
@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 / 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 / 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 / module_path.py
Last active December 12, 2015 06:29
Displays the current module name and its path. #python #path
# http://docs.python.org/reference/datamodel.html?highlight=__file__
# Current module name
print __file__
# module1.py
# Path of the current module
import os
print os.path.abspath(os.path.dirname(__file__))
# /home/myusername/projects/project1
@caglartoklu
caglartoklu / is_ironpython.py
Created February 7, 2013 09:49
If the platform is IronPython, this function returns True, False otherwise. #python #ironpython
import sys
def is_ironpython():
"""
If the platform is IronPython, this function returns True, False otherwise.
"""
result = False
if sys.platform == "cli":
result = True
return result
@caglartoklu
caglartoklu / encoding.py
Last active December 12, 2015 06:29
Python source encoding.Add the code to the top of your source file. #python #encoding
# -*- coding: utf8 -*-
# http://www.python.org/dev/peps/pep-0263/
@caglartoklu
caglartoklu / rhel_version.sh
Created February 7, 2013 09:40
Find out Red Hat Linux version #redhat #linux #shell
uname -a
cat /etc/redhat-release