Skip to content

Instantly share code, notes, and snippets.

@en4bz
en4bz / format.cpp
Last active February 21, 2017 02:37
sprintf with C++ variadic templates
#include <iostream>
#include <sstream>
#include <tuple>
template<class Tuple, std::size_t N>
struct TuplePrinter {
static void print(const std::string& fmt, std::ostream& os, const Tuple& t) {
const size_t idx = fmt.find_last_of('%');
TuplePrinter<Tuple, N-1>::print(std::string(fmt, 0, idx), os,t);
os << std::get<N-1>(t) << std::string(fmt, idx + 1);
@ajaxray
ajaxray / example.sublime-project.json
Last active May 2, 2017 17:18
Just an example of project settings file for Sublimetext 2. Shows how to set exclude patterns for files and folders, multiple folders with name etc.
{
"folders":
[
{
"path": "/Path/To/application/dir",
"folder_exclude_patterns": ["cache", "logs"],
"file_exclude_patterns": ["*_example.*", "backup_*"],
"name": "Application Name"
},
{
@reusee
reusee / gist:2406975
Created April 17, 2012 15:45
pyqt example
#!/usr/bin/env python
#############################################################################
##
## Copyright (C) 2010 Riverbank Computing Limited.
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
##
## This file is part of the examples of PyQt.
@old9
old9 / sublimeCtrlTab.ahk
Created March 20, 2014 03:00
AHK script to tune the Ctrl+Tab behavior in Sublime Text
SetTitleMatchMode RegEx
#ifWinActive, .* - Sublime Text$
*^tab up::
SetTimer, WaitForCtrlUp, 20
return
#ifWinActive
WaitForCtrlUp:
if(GetKeyState("Ctrl")){
if(GetKeyState("shift")){
@justinfx
justinfx / move_up_or_down.py
Created October 10, 2012 19:32
PyQt4 example of how to move custom widgets up and down in a layout, using a key press UP/DOWN from within the QLineEdit
from PyQt4 import QtGui, QtCore
class RenderManagement(QtGui.QWidget):
def __init__(self):
super(RenderManagement, self).__init__()
self.v_layout = QtGui.QVBoxLayout(self)
# Create 5 dynamic items
@a-r-m-i-n
a-r-m-i-n / .gitattributes
Last active July 19, 2018 09:25
.gitattributes to force LF for all text files
# Autodetect text files
* text=auto
# Force the following filetypes to have unix eols, so Windows does not break them
*.* text eol=lf
# Force images/fonts to be handled as binaries
*.jpg binary
*.jpeg binary
*.gif binary
@mattst
mattst / GetFileExtensionSyntax.py
Last active November 7, 2018 13:33
GetFileExtensionSyntax
# Proof of concept; retrieve the path of the syntax that a user has
# associated with any file extension in Sublime Text.
#
# 1) Create a temp file with the file extension of the desired syntax.
# 2) Open the temp file in ST with the API `open_file()` method; use a
# sublime.TRANSIENT buffer so that no tab is shown on the tab bar.
# 3) Retrieve the syntax ST has assigned to the view's settings.
# 4) Close the temp file's ST buffer.
# 5) Delete the temp file.
#
@awangenh
awangenh / ForwardDiff_Foley_vanDam.pde
Last active November 23, 2018 23:24
COMPUTE AND DRAW A BICUBIC SURFACE PATCH USING FORWARD DIFFERENCES - This code implements and provides corrections to the algorithm named DrawSurfaceFwdDif presented in Fig.11.46 at page 525 of the book Computer Graphics - Principles and Practice 2.ed in C by James D.Foley et.al.
/* ============================================================================= *
* COMPUTE AND DRAW A BICUBIC SURFACE PATCH USING FORWARD DIFFERENCES *
* *
* This code implements and provides corrections to the algorithm named *
* DrawSurfaceFwdDif presented in Fig.11.46 at page 525 of the book *
* Computer Graphics - Principles and Practice 2.ed in C by Jamed D.Foley et.al. *
* This algorithm was neither corrected nor repeated in the 3rd (present) *
* edition of Foley et.al.'s book. *
* *
* The algorithm, as stated in the book, does not work: There is one error and *
@typeoneerror
typeoneerror / Bash.sublime-build
Created January 11, 2012 20:18
Bash build system for running currently open script in Sublime Text 2
{
"cmd" : ["$file"],
"selector" : "source.shell",
"shell" : "bash"
}
@89465127
89465127 / cli_progress.py
Last active January 9, 2019 10:43
Simple example of how to get a python progress bar in your program.
import time
from progress.bar import Bar # sudo pip install progress
bar = Bar('Processing', max=20, suffix='%(index)d/%(max)d - %(percent).1f%% - %(eta)ds')
for i in range(20):
time.sleep(.05) # Do some work
bar.next()
bar.finish()