Skip to content

Instantly share code, notes, and snippets.

View scriptum's full-sized avatar

Pavel Roschin scriptum

View GitHub Profile
gboolean
sessionLoadWindowStates (const gchar * filename)
{
FILE *f;
gchar s[4096], s1[4096];
gint i, pos, pos1;
unsigned long w;
g_return_val_if_fail (filename != NULL, FALSE);
@scriptum
scriptum / .bashrc
Created December 16, 2014 15:13
Easy-to-remember passwords
#Type any easy to remember string to generate strong passwords.
wallet() {
read -s p; openssl sha512 -binary <<< $USER$p | base64 -w12 | nl
}
@scriptum
scriptum / matrix.sh
Created December 16, 2014 11:36
Matrix
tr -c "[:alnum:]" " " < /dev/urandom | fold -w$COLUMNS | GREP_COLOR="1;32" grep --color .
/* http://www.codersnotes.com/algorithms/signed-distance-fields */
#include <QImage>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <sys/time.h>
static inline double get_wall_time()
{
struct timeval time;
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2013 Intel Corporation
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@scriptum
scriptum / pdfoptimize.sh
Created November 25, 2014 14:20
PDF optimization script
for f in "$@"
do
TMP=$(mktemp)
SIZE_OLD=$(wc -c < "$f")
echo "Optimizing '$f' of size $SIZE_OLD"
/usr/bin/gs \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook \
-dNOPAUSE \
@scriptum
scriptum / color.sh
Last active August 29, 2015 14:10
Function to colorize bash scripts
function color() {
case $1 in
red) tput setaf 1;;
green) tput setaf 2;;
yellow) tput setaf 3;;
blue) tput setaf 4;;
purple) tput setaf 5;;
cyan) tput setaf 6;;
white) tput setaf 7;;
#bold
/* http://stackoverflow.com/questions/17432502/how-can-i-measure-cpu-time-and-wall-clock-time-on-both-linux-windows */
#include <stdio.h>
/* Windows */
#ifdef _WIN32
#include <Windows.h>
static inline double get_wall_time()
{
@scriptum
scriptum / a.cpp
Last active August 29, 2015 14:02
LTO gcc test
#include "a.hpp"
#include "stdio.h"
void A::set(int a, int b)
{
x = a;
y = b;
}
void A::get()
{
==3177== 796 (440 direct, 356 indirect) bytes in 5 blocks are definitely lost in loss record 13,568 of 14,260
==3177== at 0x4C266ED: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==3177== by 0x73D0400: g_malloc (in /usr/lib64/libglib-2.0.so.0.4000.0)
==3177== by 0x73C4145: g_key_file_get_string_list (in /usr/lib64/libglib-2.0.so.0.4000.0)
==3177== by 0x47F40C: configuration_load_session_files (keyfile.c:668)
==3177== by 0x480383: configuration_load (keyfile.c:1080)
==3177== by 0x44FB99: main (main.c:903)