Skip to content

Instantly share code, notes, and snippets.

View laszlocsontos's full-sized avatar
🏠
Working from home

László Csontos laszlocsontos

🏠
Working from home
View GitHub Profile
@laszlocsontos
laszlocsontos / start.sh
Created July 17, 2020 13:20
Starts up a Jupyter notebook environment
#!/bin/bash
env_name="venv"
source ${env_name}/bin/activate
${env_name}/bin/jupyter notebook
@laszlocsontos
laszlocsontos / init.sh
Created July 17, 2020 13:18
Initializes a virtual Python environment with Jupyter
#!/bin/bash
env_name="venv"
python3 -m venv ${env_name}
source ${env_name}/bin/activate
if [ ! -f requirements.txt ]; then
pip install numpy pandas matplotlib scipy scikit-learn jupyter jupyter-datatables
pip freeze > requirements.txt
else
@laszlocsontos
laszlocsontos / init.sh
Created July 17, 2020 13:18
Initializes a virtual Python environment with Jupyter
#!/bin/bash
env_name="venv"
python3 -m venv ${env_name}
source ${env_name}/bin/activate
if [ ! -f requirements.txt ]; then
pip install numpy pandas matplotlib scipy scikit-learn jupyter jupyter-datatables
pip freeze > requirements.txt
else
/**
* This is a workaround for https://issues.apache.org/jira/browse/WSS-584
*
* Implemented based on the following conversation with a core developer of wss4j
* https://www.mail-archive.com/users@ws.apache.org/msg00404.html
*
* Created by lcsontos on 11/28/16.
*/
public class CachingWss4jSecurityInterceptor extends Wss4jSecurityInterceptor implements DisposableBean {
@laszlocsontos
laszlocsontos / IdentityGenerator.java
Created August 24, 2017 08:13
Database agnostic unique ID generator
/**
* Database agnostic unique ID generator inspired by
* <a href="https://engineering.instagram.com/sharding-ids-at-instagram-1cf5a71e5a5c">
* Sharding & IDs at Instagram</a>
*
* <p>Going to the most to the least significant bits
* <ul>
* <li>the first bit (sign) is always zero
* <li>the next 7 bits represent the shard ID
* <li>the next 40 bits represent the elapsed milliseconds from a custom Epoch (2017-02-20)
@laszlocsontos
laszlocsontos / suitecrm_rest_login.php
Created March 30, 2017 10:06
Test PHP script for calling login method on SuiteCRM's REST API
<?php
$url = "http://{hostname}/service/v4_1/rest.php";
$username = "username";
$password = "password";
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url);
@laszlocsontos
laszlocsontos / logo_sizes.txt
Last active February 10, 2017 13:12
Logo dimensions on various social networks
Facebook 170 x 170
Twitter 200 x 200
Pinterest 156 x 156
GitHub 230 x 230
Google+ 124 x 124
Instagram 152 x 152
Vimeo 150 x 150
@laszlocsontos
laszlocsontos / getUID.java
Created February 10, 2017 12:29
64-bit unique ID generator
long getUID(byte sid, long time, byte tid, byte serial) {
return (sid & 0x7fL) << 56 | (time & 0xffffffffffL) << 16 | (tid & 0xff) << 8 | (serial & 0xff);
}
@laszlocsontos
laszlocsontos / dynamic-ws.groovy
Created October 7, 2016 18:26
Groovy script for calling a WSDL-based web service dynamically with JAX-WS API back-end by CXF
import javax.xml.namespace.QName
import javax.xml.soap.*
import javax.xml.ws.Dispatch
import javax.xml.ws.Service
import javax.xml.ws.soap.SOAPBinding
import javax.xml.xpath.XPath
import javax.xml.xpath.XPathConstants
import javax.xml.xpath.XPathFactory
// Create the message
@laszlocsontos
laszlocsontos / dynamic-ws.java
Last active October 5, 2016 16:18
Pseudo code for calling a WSDL-based web service without having to generate client stubs
import javax.xml.namespace.*;
import javax.xml.soap.*;
import org.w3c.dom.*;
// Create the message
MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage requestMessage = factory.createMessage();
// Add a header
SOAPHeader header = requestMessage.getSOAPHeader();