Skip to content

Instantly share code, notes, and snippets.

View rbrito's full-sized avatar
☹️
Having (YET another) kidney stone surgery in a few days...

Rogério Brito rbrito

☹️
Having (YET another) kidney stone surgery in a few days...
View GitHub Profile
#!/bin/sh
RS=20
get_capacity()
{
c=`i2cget -y 2 0x55 0x0c w`
return $(($c * 3570 / $RS / 1000))
}
#!/usr/bin/env ruby
$TEST_PERIOD = 60 * 61
$SAMPLE_PERIOD = 60 * 10
$CAPACITY = 1320
$RS = 20
class Array
def mean
self.inject(0) { |sum, x| sum + x } / size.to_f
@jiphex
jiphex / scanmatic.sh
Created January 16, 2011 23:42
Scans a document from the default scanner and emails it (securely) via GMail
#! /usr/bin/env bash
# scans a single document and mails it
#
# Requirements: sane, ImageMagick, tesseract, gocr, sendemail
# It would be trivially email to remove gocr, tesseract is better it seems
# You could replace ImageMagick with anything that convert PBM > something.
SCANFILE=`mktemp /tmp/scantmp.XXXXXXXX`
PBMFILE="${SCANFILE}.pbm"
@Cloudef
Cloudef / gist:1324254
Created October 29, 2011 08:58
rtorrent-mod-v3
diff -rupN src-old/command_download.cc src/command_download.cc
--- src-old/command_download.cc 2011-06-04 07:01:19.000000000 +0300
+++ src/command_download.cc 2011-10-29 11:10:41.258332501 +0300
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
@aemkei
aemkei / LICENSE.txt
Last active April 12, 2024 21:27 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@bazub
bazub / gist:3877971
Created October 12, 2012 08:17
Grayscale/Binary images using PIL
im=Image.open("1.jpg")
#im=im.rotate(1)
im.save("e.jpg")
im2=im.convert("L")
im2.save("b.jpg")
threshold = 100
im = im2.point(lambda p: p > threshold and 255)
im.save("d.jpg")
img="d.jpg"
result = tesseract.ProcessPagesWrapper(img,api)
@kokx
kokx / Facebook Hackercup Solutions.md
Last active December 11, 2015 21:09
Solutions to Facebook Hackercup. Feel free to fork and make improvements! I didn't really take much time to write this, so help on clarifying the text is very much appreciated!

Disclaimer: I have no idea if this are indeed the correct answers. I just solved the exercises like this. I think that they are right though.

I have added my own code to this gist. It is ugly as hell, just like you can expect from code created in a contest like this.

Beautiful Strings

Difficulty: easy

It is simple to see that a greedy solution is good enough.

@mstepniowski
mstepniowski / _hackercup_2013_qualifications.rst
Last active April 23, 2020 21:51
Solutions to Facebook Hacker Cup 2013 Qualification Round problems (in Python)

Beautiful strings

When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.

Given a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.

The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn't care about whether letters are uppercase or lowercase, so that doesn't affect the beauty of a letter. (Uppercase 'F' is exactly as beautiful as lowercase 'f', for example.)

You're a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?

@hubgit
hubgit / README.md
Last active December 16, 2023 14:09
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files

@Dvad
Dvad / gist:9210763
Created February 25, 2014 15:14
Add this to gtk-widget.css in MediterraneanNightTheme for gnome 3.10.
/***************
* Header bars *
***************/
.header-bar {
border-width: 0 0 1px;
border-style: solid;
border-color: shade(@borders, 0.90);
border-radius: 15px 15px 0px 0px;
box-shadow: inset 0 -1px shade(@borders, 1.30);
background-color: @theme_bg_dark_color;