Skip to content

Instantly share code, notes, and snippets.

View azakordonets's full-sized avatar

Andrew Zakordonets azakordonets

View GitHub Profile
@egonSchiele
egonSchiele / generate_valid_isbn.rb
Created August 15, 2013 20:29
Generate a valid ISBN number in ruby
def generate_valid_isbn
prefix = 978.to_s # must be 978 or 979
registration_group_element = rand(10).to_s
registrant_element = (rand(90000) + 10000).to_s
publication_element = (rand(900) + 100).to_s
_isbn = prefix + registration_group_element + registrant_element + publication_element
check_digit = 0
i = 0
_isbn.each_char do |letter|
i+= 1
@epall
epall / CustomFirefoxProfile.java
Created February 10, 2011 23:22
Setting firefox profile preferences with RemoteWebDriver
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import org.openqa.selenium.firefox.*;
public class CustomFirefoxProfile {
public static void main(String[] args) throws Exception {
DesiredCapabilities capabillities = new DesiredCapabilities("firefox", "3.6.", Platform.WINDOWS);
capabillities.setCapability("job-name", "Fancy Firefox profile");
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.http.phishy-userpass-length", 255);
@Mononofu
Mononofu / json.scala
Created September 18, 2012 11:34
Beautiful JSON handling in Scala
package EasyJSON
import net.minidev.json.JSONValue
import net.minidev.json.JSONArray
import net.minidev.json.JSONObject
import scala.collection.JavaConversions._
object JSON {
def parseJSON(s: String) = new ScalaJSON(JSONValue.parse(s))
@penland365
penland365 / PercentEncoder
Created March 16, 2014 03:27
A Scala Object to do simple RFC3986 URL encoding.
package com.sabrelabs.twitter.auth
import scala.collection.BitSet
import scala.annotation.tailrec
import scala.runtime.RichInt
import scala.collection.mutable.ListBuffer
object PercentEncoder {
def encodeRFC3986(str: String): String = {
@andriisoldatenko
andriisoldatenko / latency.txt
Last active February 18, 2018 07:16 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@dmitriy-kiriyenko
dmitriy-kiriyenko / console
Created May 16, 2011 12:51
Init.d to start/stop xvfb. Put it into /etc/init.d and chmod it to 755
apt-get install xvfb
apt-get install firefox
@makotom
makotom / isbn.js
Last active March 10, 2019 14:44
ISBN tools by JS
var ISBN = (function(){
"use strict";
var validateISBN13 = function(isbnChars){
var checksum = 0;
isbnChars.forEach(function(isbnChar, key){
checksum += parseInt(isbnChar, 10) * (key % 2 === 1 ? 3 : 1);
});
@tarun3kumar
tarun3kumar / seemailverify.java
Last active July 26, 2020 23:28
Selenium email verification
import javax.mail.Authenticator;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.internet.InternetAddress;
import javax.mail.search.FromTerm;
import React from 'react'
import {render} from 'react-dom'
import {Chart} from 'react-google-charts'
export default class App extends React.Component {
constructor(props) {
super(props)
this.state = {
data: [],
@archagon
archagon / playlist-to-podcast.py
Created September 28, 2012 07:03
A script that downloads videos from YouTube playlists, extracts their audio, and only downloads missing files each time it's run. Also generates an iTunes-compliant podcast xml file for private hosting purposes. Requires youtube-dl, ffmpeg, and ffprobe.
# YouTube playlist audio retreiver and iTunes-compliant podcast XML generation tool.
# This script will download each video file from the specified YouTube playlist, losslessly extract
# the audio, delete the video, and ultimately produce an iTunes-compliant podcast XML with the
# appropriate metadata, including chapter markers (if provided in the description). If you run the
# script again, only videos that haven't already been converted will be downloaded, allowing you to
# schedule the script to run as often as needed without stressing your internet connection or
# hard drive space. After generating the files and xml, you can easily host them on a local server
# in order to use them with iTunes or your favorite podcast aggregator -- but that's beyond this
# script's jurisdiction.