Skip to content

Instantly share code, notes, and snippets.

Peter Vojtek petervojtek

Block or report user

Report or block petervojtek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@petervojtek
petervojtek / gist:c79bb05643f33dc0e44d1b993569f1d9
Created Mar 15, 2018
embed IntlProvider into another IntlProvider
View gist:c79bb05643f33dc0e44d1b993569f1d9
<IntlProvider locale="en" messages={messages} >
<FormattedMessage {...message.hello} />
<IntlProvider locale="fr" messages={messages} >
<FormattedMessage {...message.hello} />
</IntlProvider>
</IntlProvider>
// https://stackoverflow.com/questions/49104657/is-it-possible-to-override-locale-of-one-specific-intl-formatmessage/
@petervojtek
petervojtek / react-jquerybuilder-datepicker.js
Last active Nov 9, 2017
How to add datepicker to jQueryBuilder in ReactJS
View react-jquerybuilder-datepicker.js
// important point is that the datepicker is not jQueryBuilder's plugin, but jquery-ui plugin being injected into jquery ($).
// order of imports matters -- the datepicker plugin is injected automatically into jquery and then automatically adopted by jQueryBuilder
import $ from 'jquery';
import datepicker from 'jquery-datepicker'; // https://www.npmjs.com/package/jquery-datepicker
import jQueryBuilder from 'jQuery-QueryBuilder'; // https://www.npmjs.com/package/jQuery-QueryBuilder
// this is how we initialize the query builder
$('#builder-widgets').queryBuilder({
filters: [{
@petervojtek
petervojtek / freemap.jsx
Created Jun 26, 2017
next.freemap.sk #142 - dd/dt/dl for changeset detail
View freemap.jsx
const message = (
<dl className="dl-horizontal">
<dt>Autor:</dt>
<dd>
<a
href={`https://www.openstreetmap.org/user/${encodeURIComponent(changeset.userName)}`}
target="_blank"
rel="noopener noreferrer"
>{changeset.userName}</a>
View ionic.console
peter@ubuntu:~/repos/TestProject$ rm -r node_modules/
peter@ubuntu:~/repos/TestProject$ node -v
v5.8.0
peter@ubuntu:~/repos/TestProject$
peter@ubuntu:~/repos/TestProject$
peter@ubuntu:~/repos/TestProject$ npm install
npm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
@petervojtek
petervojtek / gist:ca5475afd4eace9a7287
Last active Jan 30, 2016
bind not working for sinatra web server
View gist:ca5475afd4eace9a7287

I was trying to post this answer to stackoverflow but I was banned to do that. I believe the answer below may be helpful so I publish it at least this way:

I was running sinatra via

Rack::Handler::WEBrick.run MyServer, webrick_options

and after installing sinatra-contrib gem suddenly I was unable to to access my app from outside (localhost was working perfectly). All the hints with bind and -o were not working for me. What finally helped was to put inside webrick_options hash following key and value:

:Host => 'myserver.com'
@petervojtek
petervojtek / zrsr.rb
Created Apr 28, 2015
Zivnostnensky register z Ruby (zrsr.sk)
View zrsr.rb
# kod nizsie vyhlada zivnostnikov ktori maju ako obec uvedene Malinovo
require 'uri'
require 'net/http'
uri = URI('http://www.zrsr.sk/zr_om.aspx')
res = Net::HTTP.get_response(uri)
require 'nokogiri'
doc = Nokogiri::HTML.parse res.body
View wma-to-mp3.rb
Dir.chdir ARGV[0]
wmas = Dir.glob("*.wma")
wmas.each do |wma|
wma = File.basename wma
mp3 = "#{wma.gsub(/[[:space:]]/,'').downcase[0..-4]}mp3"
puts "processing #{wma} to #{mp3}"
`avconv -i \"#{wma}\" -acodec libmp3lame -ab 128k #{mp3}`
end
`rm *.wma`
@petervojtek
petervojtek / obce.rb
Last active Aug 29, 2015
zhlukovanie obci SR podla podobnosti nazvu (jedno pismenko sa moze lisit v ramci danej skupiny)
View obce.rb
# http://petervojtek.eu/wiki/Bike/2014-08-10Cyklookruh%C4%8Cekovce-%C4%8Celovce-%C4%8Cebovce
# encoding: utf-8
villages_full_names = File.read('obce.txt').split "\n"
#villages = ["Ďurkovce", "Hrkovce", "Markovce", "Mirkovce", "Širkovce", "Hokovce"]
villages = villages_full_names.collect{|v| v.sub(/ \/ .+/, '')} # Abrahámovce / okres Bardejov -> Abrahámovce
similar_villages = {}
View people-counter-v1.ino
#include <lowpower.h>
#include <EEPROM.h>
int currentSessionId;
int humanCount = 0;
int eepromHumanCount = 0;
long eepromLastSyncAt = 0;
const int trigPin = 9;
const int echoPin = 10;
@petervojtek
petervojtek / HC-SR04.ino
Created Feb 13, 2014
HC-SR04 with power on and off to save power. Not working properly due to unknown reason. discussion here: http://forum.arduino.cc/index.php?topic=216079.0
View HC-SR04.ino
const int trigPin = 6;
const int echoPin = 7;
const int powerPin = 5;
const int ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(powerPin, OUTPUT);
pinMode(trigPin, OUTPUT);
You can’t perform that action at this time.