Skip to content

Instantly share code, notes, and snippets.

View JAlexoid's full-sized avatar

Aleksandr Panzin JAlexoid

View GitHub Profile
@JAlexoid
JAlexoid / update_ip.py
Created November 28, 2022 05:36
Update Route53 IP with your current external IP
import boto3
from requests import get
client = boto3.client('route53')
ip = get('https://api.ipify.org').text
ipv6 = get('https://api64.ipify.org').text
HostedZoneId='(HOSTED ZONE ID)'
package com.example.jersey;
import javax.net.ssl.*;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Configuration;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
@JAlexoid
JAlexoid / NowPlayingVelocity.js
Created June 14, 2014 08:53
A simple Twitter feed consumer that calculates the velocity of a hash tag. Using Node.JS and Twitter module
var util = require('util'),
twitter = require('twitter'),
sys = require('sys');
var twit = new twitter({
consumer_key: '',
consumer_secret: '',
access_token_key: '',
access_token_secret: ''
});
@JAlexoid
JAlexoid / ValueConverter.java
Created May 24, 2013 16:27
This is a simple converter for XStream that puts the text node of the tag into the specified field and redirects other processing to ReflectionConverter. Specially convenient for cases where the tags can have both text and elements. Will handle elements such as <a>text</a>, <a><b>other contents</b>some text</a> and <a><b>some contents</b><c>some…
package eu.activelogic.xml.xstream.converters;
import java.lang.reflect.Field;
import org.apache.commons.lang.StringUtils;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.ConverterLookup;
import com.thoughtworks.xstream.converters.MarshallingContext;
def key(time, base, adjustment):
return (time+adjustment) - (time+adjustment)%base
def map_entries(index, entry):
if entry.type == "call":
yield (entry.number+entry.number_to+key(entry.time, 5*60, 0), entry)
elif entry.type == "SMS":
yield (entry.number+entry.number_to+key(entry.time, 5*60, 0), entry)
yield (entry.number+entry.number_to+key(entry.time, 5*60, -5*60), entry)
else:
def map_entries(index, entry):
if entry.type == "call" or entry.type == "SMS":
(entry.number, entry)
else:
(None, None)
def reduce_entries(key, entries):
for i in range(0, len(entries)) :
entry = entries[i]
def map_entries(index, entry):
return (entry.number, entry)
def reduce_entries(key, entries):
for i in range(0, len(entries)) :
entry = entries[i]
if entry.type == "call":
sms = find_sms(entries,
entry.number_to,
def find_sms(number, number_to, start, time_start, time_end):
for i in range(start, len(source)) :
entry = source[i]
if (entry.type == "sms" and
entry.number == number and
entry.number_to == number_to and
entry.time > time_start and
entry.time < time_end) :
return entry
elif entry.time > time_end:
def find_sms(number, number_to, time_start, time_end):
for entry in source:
if (entry.type == "sms" and
entry.number == number and
entry.number_to == number_to and
entry.time > time_start and
entry.time < time_end) :
return entry
for entry in source :