Skip to content

Instantly share code, notes, and snippets.

@joubin
joubin / CenterLatLon.py
Last active March 4, 2016 17:57
Python method to find the center of a multiple positions
import math
import unittest
class LatLon(object):
def __init__(self, lat, lon, alt):
"""
:param lat: Latitude in radians
:param lon: Longitude in radians
:param alt: Altitude in any unit
package so;
import javax.crypto.Cipher;
import javax.crypto.KeyAgreement;
import javax.crypto.SecretKey;
import javax.crypto.interfaces.DHPublicKey;
import javax.crypto.spec.DHParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.*;
import java.security.spec.X509EncodedKeySpec;
var cookieValue = readCookie("sessionID");
console.log(cookieValue);
if (cookieValue === undefined){
document.write("First visit!<br>Will write session id to cookie now")
document.cookie = "sessionID=1000";
}else{
document.write("Session id: " + cookieValue);
}
@joubin
joubin / report.xml
Created February 8, 2017 06:12
lottie report from VisualCodeGrepper
<?xml version="1.0" encoding="utf-8"?>
<!--XML Export of VCG Results for directory: . Scanned for Java security issues.-->
<CodeIssueCollection>
<CodeIssue>
<Priority>5</Priority>
<Severity>Low</Severity>
<Title>Operation on Primitive Data Type</Title>
<Description>The code appears to be carrying out a mathematical operation on a primitive data type. In some circumstances this can result in an overflow and unexpected behaviour. Check the code manually to determine the risk.</Description>
<FileName>Z:\Users\joubin\Downloads\scanthis\lottie\src\main\java\com\airbnb\lottie\AnimatableColorValue.java</FileName>
<Line>18</Line>
@joubin
joubin / updateContacts.scpt
Last active December 3, 2024 11:45
If you are like me, you've carried over your contacts for many years. Sometimes from the years where you didn't have any contacts in different area codes. Over the years, I've updated the contacts without area codes manually. Recently, I left the country and ran into a problem calling US numbers with a European sim in my phone. The cooperate, no…
tell application "Contacts"
repeat with eachPerson in people
repeat with eachNumber in phones of eachPerson
set theNum to (get value of eachNumber)
if (theNum does not start with "+" and (theNum does not start with "1" and theNum does not start with "0")) then
set value of eachNumber to "+1" & theNum
else if (theNum starts with "1") then
set value of eachNumber to "+" & theNum
end if
end repeat
Map<String, Object> commentMap = (new JacksonJsonParser()).parseMap(commentStr);
String textComment = String.valueOf(commentMap.get("text"));
String htmlEscapedTextComment = HtmlUtils.htmlEscape(textComment);
commentMap.put("text", htmlEscapedTextComment);
try {
commentStr = (new ObjectMapper()).writeValueAsString(commentMap);
} catch (JsonProcessingException ignored) {
}
PreparedStatement statement = connection.prepareStatement("SELECT * FROM user_data WHERE last_name = ?",
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
statement.setString(1, accountName);
<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE author [
<!ELEMENT author (#PCDATA)>
<!ELEMENT foo ANY >
<!ENTITY js "Testing 123">
<!ENTITY test "something">
]>
<foo>
<author>&test;</author>
<foo>&js;</foo>
JWTVerifier verifier = new JWTVerifier(JWT_PASSWORD);
verifier.verify(accessToken);
System.out.println(xstream.getClass().getPackage().getImplementationVersion());
XStream.setupDefaultSecurity(xstream);
xstream.allowTypes(new Class[]{Contact.class});