Skip to content

Instantly share code, notes, and snippets.

View kovacshuni's full-sized avatar

Hunor Kovács kovacshuni

View GitHub Profile
@kovacshuni
kovacshuni / lol
Created November 20, 2012 15:53
lol
#define true false //happy debugging motherfuckers :))))
@kovacshuni
kovacshuni / something
Last active December 19, 2015 10:19
Some modification.
bool Demarc::has(Port p) const throw() {
Mutex::Lock _l(_ports_m);
return (_ports.count(p));
}
@kovacshuni
kovacshuni / ft-video-monitoring.rb
Created July 22, 2013 08:13
Sanity check of video.ft.com
require 'net/http'
def fetch(uri_str, limit = 10)
raise ArgumentError, 'too many HTTP redirects' if limit == 0
response = Net::HTTP.get_response(URI(uri_str))
case response
when Net::HTTPSuccess then
response.body()[/<span class="video\-length">\s*(\d+:\d+ min)\s*<\/span>/]
when Net::HTTPRedirection then
location = response['location']
@kovacshuni
kovacshuni / generate-uuid.rb
Created July 22, 2013 08:45
Generating UUID
require "active_support"
p SecureRandom.uuid
@kovacshuni
kovacshuni / gist:9466066
Created March 10, 2014 14:34
Ansible command ran directly
## So this is how i copied a file from src to dest through an Ansible command.
ansible -i poc gitlab-servers -m file -a "name=copying src=/home/git/gitlab/lib/support/logrotate/gitlab dest=/etc/logrotate./gitlab mode=0640 owner=root group=git"
server | success >> {
"changed": false,
"path": "copying",
"state": "absent"
}
@kovacshuni
kovacshuni / hmac-sha1.rb
Last active March 12, 2022 15:05
Ruby HMAC-SHA1 digest creation
require 'base64'
require 'cgi'
require 'openssl'
base = 'POST&https%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.json&include_entities%3Dtrue%26oauth_consumer_key%3Dxvz1evFS4wEEPTGEFPHBog%26oauth_nonce%3DkYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1318622958%26oauth_token%3D370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb%26oauth_version%3D1.0%26status%3DHello%2520Ladies%2520%252B%2520Gentlemen%252C%2520a%2520signed%2520OAuth%2520request%2521'
key = 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw&LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE'
puts CGI.escape(Base64.encode64("#{OpenSSL::HMAC.digest('sha1', key, base)}\n"))
@kovacshuni
kovacshuni / hs_err_pid9709.log
Created September 16, 2014 19:33
Can't set memory settings for `sbt start`
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 715849728 bytes for committing reserved memory.
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
@kovacshuni
kovacshuni / app.js
Created October 2, 2014 11:37
Joining promises
app.controller('SomeController', ['$http', function($http) {
var requestA = function () {
$http.post('http://incoming.example.com:9000/v1.0/oauth1/request-token', {})
.success(function(data) {
...
})
.error(function(data, status) {
...
});
@kovacshuni
kovacshuni / Proxy.scala
Created June 10, 2015 00:27
akka-http-streams-proxy
package sample.stream
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.headers.RawHeader
import akka.http.scaladsl.server.Route
import akka.stream.ActorFlowMaterializer
import akka.stream.scaladsl.{Sink, Source}
object Proxy extends App {
@kovacshuni
kovacshuni / findbyuuid
Created September 28, 2015 11:11
Finding in mongoDB by BSON serialised uuid.
db.methode.find({"uuid": BinData(4,UUID("5b175a2e47d711e4a7d4002128161462").base64())})