Skip to content

Instantly share code, notes, and snippets.

View romuloceccon's full-sized avatar

Rômulo Ceccon romuloceccon

  • Frankfurt am Main, Deutschland
View GitHub Profile
@romuloceccon
romuloceccon / python-2.6.9.patch
Created December 14, 2017 13:22
A patch to compile Python 2.6 in a 64-bit Linux distribution with a custom OpenSSL version
--- a/setup.py 2013-10-29 16:04:39.000000000 +0100
+++ b/setup.py 2017-12-14 12:30:22.280645847 +0100
@@ -137,6 +137,20 @@
log.info("WARNING: multiple copies of %s found"%module)
return os.path.join(list[0], module)
+def find_compiler_search_dirs(compiler):
+ child = os.popen('%s -Xlinker --verbose 2>&1' % (compiler,))
+
+ for line in child.read().split('\n'):
://paywall\.folha\.uol\.com\.br/
/disablecopy\.js$
://securepubads\.g\.doubleclick\.net/
://securepubads\.g\.doubleclick\.net/
@romuloceccon
romuloceccon / emacs.el
Last active September 6, 2018 10:33
My .emacs
(package-initialize)
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/") t)
;; --- begin my settings ---
(defun switch-whitespace-mode-and-set-line-length-to-79 (a b c)
"Switches `whitespace-mode' on and sets line length to 79.
@romuloceccon
romuloceccon / open-printscreen.sh
Created October 20, 2017 16:25
Opens the printscreen file generated by Byobu via Shift+F7
#! /bin/bash
[[ -z "$BYOBU_RUN_DIR" ]] && \
echo "Not a Byobu session!" 1>&2 && exit 1
[[ ! -e $BYOBU_RUN_DIR/printscreen ]] && \
echo "No printscreen found! (try pressing Shift+F7)" 1>&2 && exit 1
geany $BYOBU_RUN_DIR/printscreen
@romuloceccon
romuloceccon / start-ssh-agent.sh
Created July 6, 2017 12:30
Small script to start an ssh-agent instance or initialize session with variables from an existing one (put at the end of your .bashrc)
SSH_FILE=$HOME/.ssh-agent-data
if [[ -z "$SSH_AUTH_SOCK" ]]
then
[[ -f "$SSH_FILE" ]] && SSH_VARS=($(cat $SSH_FILE)) || SSH_VARS=()
if [[ -z "${SSH_VARS[@]}" || ! -S "${SSH_VARS[0]}" ]]
then
eval "$(ssh-agent)"
echo $SSH_AUTH_SOCK $SSH_AGENT_PID> $SSH_FILE
@romuloceccon
romuloceccon / YahooFinance.js
Last active June 8, 2017 14:18
Google Spreadsheets function to fetch stock financial data from Yahoo Finance API
/**
* Fetches data from Yahoo Finance API.
*
* Using a single query to the Yahoo Finance API this function fetches multiple
* properties from a given symbol. Each property will be assigned a single
* column. If the property is a value with "raw" and "fmt" attributes, the value
* of "raw" is returned. Otherwise the property's value is returned.
*
* For example: given the expression YAHOOFINANCE("PETR4.SA",
* "defaultKeyStatistics/forwardPE,financialData/recommendationKey"), the first
@romuloceccon
romuloceccon / divmod.c
Last active March 17, 2017 13:28
How to calculate modulo division (like Python's divmod) in C without conditionals (also works in Java)
#include <stdio.h>
int main()
{
int i;
static const int dm = 4;
for (i = -2 * dm; i < 2 * dm; i++) {
int rem = i % dm;
int mod = (rem + dm) % dm;
@romuloceccon
romuloceccon / printable-code-points.py
Created March 15, 2017 13:01
182 printable unicode code points to be used in a base-32768 encoder
def is_printable(x):
return \
x >= 0x25 and x <= 0x2a or \
x >= 0x2c and x <= 0x3c or \
x >= 0x3e and x <= 0x7e or \
x >= 0xa1 and x <= 0xac or \
x >= 0xae and x <= 0xff
s = [chr(x) for x in range(256) if is_printable(x)]
@romuloceccon
romuloceccon / atom-custom-path.patch
Created March 14, 2017 11:37
Patch to install Atom in custom location
diff --git a/script/lib/install-application.js b/script/lib/install-application.js
index be790b4..477265b 100644
--- a/script/lib/install-application.js
+++ b/script/lib/install-application.js
@@ -39,7 +39,7 @@ module.exports = function (packagedAppPath) {
const apmExecutableName = CONFIG.channel === 'beta' ? 'apm-beta' : 'apm'
const appName = CONFIG.channel === 'beta' ? 'Atom Beta' : 'Atom'
const appDescription = CONFIG.appMetadata.description
- const userLocalDirPath = path.join('/usr', 'local')
+ const userLocalDirPath = '/home/romulo/opt/atom'
@romuloceccon
romuloceccon / assign-race-condition.rb
Last active December 19, 2020 16:24
Demonstrates how Ruby's idiom "my_var ||= MyObject.new" is NOT thread safe, as part of discussion at https://github.com/svenfuchs/i18n/pull/352#pullrequestreview-24816351. The script returns when a race condition is detected.
class MyObject
def initialize
@data = 'x' * 1_000_000
end
def inspect
object_id
end
end