Skip to content

Instantly share code, notes, and snippets.

@alepez
alepez / busybox-date-operations.sh
Created March 30, 2015 09:55
busybox date timestamp 1 hour ago
echo "$(( $( date +%s ) - 3600 ))"
@alepez
alepez / ipv4_sockaddr_to_human_readable_ip.cpp
Created May 12, 2015 15:48
ipv4 sockaddr to human readable ip
#include <netdb.h>
#include <arpa/inet.h>
#include <iostream>
#include <cstring>
#include <stdexcept>
int main(int argc, char* argv[]) {
if (argc < 2) {
return 0;
}
@alepez
alepez / hexencode.cpp
Created May 13, 2015 09:54
hex encode
#include <string>
#include <vector>
#include <iostream>
using byte = uint8_t;
static std::string hexEncode(const std::vector<uint8_t>& data) {
std::string result(data.size() * 3, ' ');
for (size_t i = 0, k = 0; k < result.size(); ++i, k += 3) {
static const char hex[] = "0123456789abcdef";
@alepez
alepez / selectmenu-blur-event.js
Created May 22, 2015 14:23
selectmenu blur event
// You can access the `focusable` element of selectmenu instance:
$('SELECTOR').selectmenu('instance').focusable.blur(function() {
// this is executed when selectmenu looses focus
});
@alepez
alepez / LiveReloadMake.py
Created June 4, 2015 15:17
LiveReloadMake
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import threading
import subprocess
import sys
import sublime
import sublime_plugin
@alepez
alepez / LiveReloadMake.py
Last active August 29, 2015 14:22
LiveReloadMake - LiveReload Make extension for Sublime Text 3
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import threading
import subprocess
import sys
import sublime
import sublime_plugin
@alepez
alepez / ssh-stupid-ntp.sh
Created June 30, 2015 12:54
set datetime taken from remote via ssh (when ntp isn't available)
sudo date -s "$( ssh user@host 'date "+%Y-%m-%d %H:%M:%S"' )"; sudo hwclock --systohc
#############################################################################
# Makefile for building: qt-hello
# Generated by qmake (3.0) (Qt 5.2.0)
# Project: qt-hello.pro
# Template: app
# Command: /home/pez/workspace/esa-universal/sdk/toolchain/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/qmake
-spec /home/pez/workspace/esa-universal/sdk/usr/mkspecs/devices/linux-imx6-g++ -o Makefile qt-hello.pro
#############################################################################
MAKEFILE = Makefile
static int aStrangeFunction() {
return ({ std::string xxx{"the answer is"}; 42; });
}
TEST(AStrangeFunction, AlwaysReturnTheAnswer) {
ASSERT_EQ(42, aStrangeFunction());
}
alias svndiff="svn diff | colordiff | less"