Skip to content

Instantly share code, notes, and snippets.

View igorrendulic's full-sized avatar

Igor Rendulic igorrendulic

View GitHub Profile
@igorrendulic
igorrendulic / Nginx reverse proxy config for Tomcat7 on Debian
Last active June 21, 2016 18:32
Nginx reverse proxy config for Tomcat7 on Debian and 413 File too Large problem
Tomcat7 add to config:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="administracija">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
@igorrendulic
igorrendulic / .gitignore
Created March 11, 2017 21:56
gitignore java maven eclipse intellij
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
@igorrendulic
igorrendulic / ISO-3166-Countries-with-Regional-Codes.json
Created March 23, 2017 09:11
ISO 3166 Countries with Regional Codes JSON
{
"BD": {
"alpha_2": "BD",
"name": "Bangladesh"
},
"BE": {
"alpha_2": "BE",
"name": "Belgium"
},
"BF": {
@igorrendulic
igorrendulic / FindSubarrayInArray.java
Last active April 19, 2017 17:24
Find number of times subarray repeats in an array
/**
* Finding number of times subarray repeats in array <br>
* @param array must be >= @param subarray
* @return # of subarray repeats or 0
*/
public int findSubarrayCount(List<String> array, List<String> subarray, int fromIndex) {
int cntTotal = 0;
String firstElement = null;
if (subarray.size() > 0) {
@igorrendulic
igorrendulic / iosscroll.css
Last active August 25, 2017 18:51
Momentum Scrolling on iOS Overflow Elements
body {
padding: 20px;
}
div {
width: 200px;
height: 200px;
margin-right: 20px;
overflow-y: scroll; /* has to be scroll, not auto */
float: left;
@igorrendulic
igorrendulic / MailgunWebhook.java
Last active December 3, 2017 22:19
MailGun Webhook Handler
public class MailgunWebhook extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
resp.setContentType("application/json");
String token = null;
@igorrendulic
igorrendulic / MailGun.java
Created December 3, 2017 22:17
MailGun Webhook Signature Validation
private static final key = "mailgun_key"
public static boolean isSignatureValid(String token , long timestamp, String signature) {
try {
Mac hmac = Mac.getInstance("HmacSHA256");
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
hmac.init(signingKey);
String signed = Hex.encodeHexString(hmac.doFinal((timestamp + token).getBytes()));
if (signed.equals(signature)) {
return true;
}
# (tested on Ubuntu 18.04 Desktop)
# Stream your own desktop to RTMP
ffmpeg -f x11grab -s 1920x1200 -framerate 15 -i :0.0 -c:v libx264 -preset fast -pix_fmt yuv420p -s 1280x800 -threads 0 -f flv "rtmp://127.0.0.1/live/mystreamkey"
# Broadcasting Examples
ffmpeg -f dshow -i video="Virtual-Camera" -preset ultrafast -vcodec libx264 -tune zerolatency -b 900k -f mpegts udp://127.0.0.1:1234
ffmpeg -f dshow -i video="screen-capture-recorder":audio="Stereo Mix (IDT High Definition" \
created - A container that has been created (e.g. with docker create) but not started
restarting - A container that is in the process of being restarted
running - A currently running container
paused - A container whose processes have been paused
exited - A container that ran and completed ("stopped" in other contexts, although a created container is technically also "stopped")
dead- A container that the daemon tried and failed to stop (usually due to a busy device or resource used by the container)
raspivid -t 0 -w 640 -h 480 -fps 15 -hf -b 1000000 -o - | \
> gst-launch-1.0 fdsrc ! h264parse config-interval=2 ! flvmux ! rtmpsink location='rtmp://127.0.0.1/live live=1'