Skip to content

Instantly share code, notes, and snippets.

@gubatron
gubatron / CMakeList.txt
Last active January 22, 2020 04:55
CMakeList.txt for Bitcoin Unlimited + macOS CLion IDE based development
#
# Author: Angel Leon (@gubatron)
# October 2nd 2018
#
#
# README:
#
# This CmakeLists.txt file is not meant to produce any executables or libraries.
#
# It has been created for CLion or any other cmake compatible IDE users so that they can
@sanchezzzhak
sanchezzzhak / clickhouse-get-tables-size.sql
Created January 18, 2018 13:43
clickhouse get tables size
SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table
@kantoniak
kantoniak / chrono-unixtimestamp.cpp
Created April 13, 2017 12:04
std::chrono example - getting unix timestamp
#include <chrono>
#include <ctime>
#include <iostream>
int main() {
// std::chrono only
auto now = std::chrono::system_clock::now();
std::cout << "std::chrono only: " << std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count() << std::endl;
@jingzhehu
jingzhehu / CMakeLists.txt
Created February 26, 2017 15:36
Clion meets bitcoin.
cmake_minimum_required(VERSION 3.3)
project(bitcoin)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_custom_target(build-bitcoin ALL
COMMAND ./autogen.sh
COMMAND ./configure
COMMAND $(MAKE) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@fenbf
fenbf / sfinae_tostring_ex.cpp
Created February 9, 2016 20:33
C++ SFINAE example: how to detect if a class contains ToString method
// SFINAE, enable_if example
// based on http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
#include <iostream>
#include <type_traits>
class ClassWithToString
{
public:
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@msrose
msrose / combining-git-repositories.md
Last active May 8, 2024 22:35
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.

# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@balupton
balupton / README.md
Created July 3, 2013 23:25
Android Emulator

Android Emulator

  1. Download Android Studio
  2. Create a virtual device: /Applications/Android\ Studio.app/sdk/tools/android create avd -n <name> -t 1
  3. List your virtual devices: /Applications/Android\ Studio.app/sdk/tools/android list avd
  4. Run your virtual device: /Applications/Android\ Studio.app/sdk/tools/emulator -avd basic
@matthewmccullough
matthewmccullough / git-compressing-and-deltas.md
Created May 14, 2012 19:05
Git, Compression, and Deltas - An explanation

Git Compression of Blobs and Packfiles.

Many users of Git are curious about the lack of delta compression at the object (blob) level when commits are first written. This efficiency is saved until the pack file is written. Loose objects are written in compressed, but non-delta format at the time of each commit.

A simple run though of a commit sequence with only the smallest change to the image (in uncompressed TIFF format to amplify the observable behavior) aids the understanding of this deferred and different approach efficiency.

The command sequence:

Create the repo: