Skip to content

Instantly share code, notes, and snippets.

View keineahnung2345's full-sized avatar
:octocat:
Focusing

keineahnung2345

:octocat:
Focusing
View GitHub Profile
@marcospereira
marcospereira / logging.rake
Created October 15, 2009 17:50
Logging SQL for Rails Migrations
namespace "db" do
namespace "migrate" do
desc "migrations logging sql"
task "logging" => :environment do
connection = ActiveRecord::Base.connection
class << connection
alias :original_exec :execute
def execute(sql, *name)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@timofurrer
timofurrer / gist:2725779
Created May 18, 2012 15:11
C++ convert string to every type using template function
template <typename T>
T ConvertString( const std::string &data )
{
if( !data.empty( ))
{
T ret;
std::istringstream iss( data );
if( data.find( "0x" ) != std::string::npos )
{
iss >> std::hex >> ret;
@MarioRicalde
MarioRicalde / git-recover-branch.md
Created October 29, 2012 01:30 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted

Oops! I accidentally deleted a local git branch, and I haven't pushed it to a remote server yet. The branch has several important commits, and it hasn't been merged with any other branches yet. How do I find the missing branch?

1. Create a list of all dangling or unreachable commits.

$ git fsck --full --no-reflogs --unreachable --lost-found
unreachable tree 4a407b1b09e0d8a16be70aa1547332432a698e18
unreachable tree 5040d8cf08c78119e66b9a3f8c4b61a240229259
unreachable tree 60c0ce61b040f5e604850f747f525e88043dae12
unreachable tree f080522d06b9853a2f18eeeb898724da4af7aed9
@ialhashim
ialhashim / fitting3D.cpp
Created November 14, 2014 23:17
Fitting 3D points to a plane or a line
template<class Vector3>
std::pair<Vector3, Vector3> best_plane_from_points(const std::vector<Vector3> & c)
{
// copy coordinates to matrix in Eigen format
size_t num_atoms = c.size();
Eigen::Matrix< Vector3::Scalar, Eigen::Dynamic, Eigen::Dynamic > coord(3, num_atoms);
for (size_t i = 0; i < num_atoms; ++i) coord.col(i) = c[i];
// calculate centroid
Vector3 centroid(coord.row(0).mean(), coord.row(1).mean(), coord.row(2).mean());
@waldyrious
waldyrious / CMakeLists.txt
Last active October 19, 2020 16:09
VTK Hello World: display a 2D image
cmake_minimum_required (VERSION 3.0)
project(VtkJpegViewer)
set(CMAKE_PREFIX_PATH "C:/Path/To/vtk-6.3.0")
find_package(VTK 6 REQUIRED)
include(${VTK_USE_FILE})
@jerome-labidurie
jerome-labidurie / index.html
Created October 17, 2015 14:01
Synology SSO server login example
<html>
<head>
<!-- include Synology SSO js -->
<script src="http://ds:5000/webman/sso/synoSSO-1.0.0.js"></script>
</head>
<body>
<script>
/** Display login/logout button.
@ryerh
ryerh / tmux-cheatsheet.markdown
Last active June 10, 2024 17:21 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表 & 简明教程

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active June 13, 2024 07:46
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@umayr
umayr / recover-deleted-branch.sh
Created April 1, 2016 11:41
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}