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 / devices
Last active Oct 25, 2017
shell script to print list of devices( and ip addresses) connected to ZyXEL P-660HW-T3v2 router
View devices
#!/usr/bin/ruby
# zyxel P-660HW-T3v2 router
# purpose of this script: print list of connected devices (ip + device hostname) to shell
# example: peter@peter-laptop:~/$ ./devices
#
# 10.0.0.34 peter-laptop
# 10.0.0.36 android-d8006
# 10.0.0.38 Notebook
# 10.0.0.40 raspberrypi
@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 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;
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 / btraced.rb
Last active Jan 3, 2016
Simple Btraced server in Ruby.
View btraced.rb
require 'stringio'
require 'active_support/core_ext/hash'
require 'json'
require 'sinatra'
get '/' do
'I am btraced server, send POST requests to me '
end
post '/' do
View wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
Modem = /dev/ttyUSB0
; Baud = 9600
Init4 = AT+CGDCONT=1,"IP","internet"
Stupid Mode = 1
View shutdown-raspberry-pi.rb
require 'rubygems'
require 'pi_piper'
include PiPiper
press_times = []
after :pin => 25, :goes => :down do
now = Time.now
press_times.each{|t| puts (now - t) }
You can’t perform that action at this time.