Skip to content

Instantly share code, notes, and snippets.

View Khalian's full-sized avatar

Arunav Sanyal Khalian

  • Vancouver, BC, Canada
View GitHub Profile
class Solution {
func compareVersion(version1: String, _ version2: String) -> Int {
var v1 = version1.characters.split(".").map { Int(String($0)) }
var v2 = version2.characters.split(".").map { Int(String($0)) }
var result = 0
for i in 0..<max(v1.count,v2.count) {
let left = i >= v1.count ? 0 : v1[i]
let right = i >= v2.count ? 0 : v2[i]
if (left == right) {
@kawaz
kawaz / install_neovim_to_amazonlinux.sh
Last active April 6, 2024 13:57
install neovim to amazonlinux
#!/usr/bin/env bash
sudo yum groups install -y Development\ tools
sudo yum install -y cmake
sudo yum install -y python34-{devel,pip}
sudo pip-3.4 install neovim --upgrade
(
cd "$(mktemp -d)"
git clone https://github.com/neovim/neovim.git
cd neovim
make CMAKE_BUILD_TYPE=Release
@zchee
zchee / actionlist.vim
Last active April 19, 2024 13:22
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@NKjoep
NKjoep / ua-analyzer.jsp
Last active October 27, 2016 00:07
JSP User Agent analyzer
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ua" value="${fn:toLowerCase(header['User-Agent'])}" />
<c:set var="chrome" value="${fn:contains(ua, 'chrome') && !fn:contains(ua, 'msie')}" />
<fmt:formatNumber var="chrome_version" value="${ chrome ? fn:substringBefore(fn:substringAfter(ua, 'chrome/'), '.') : 0}" />
<c:set var="ff" value="${fn:contains(ua, 'firefox') && !fn:contains(ua, 'opera')}" />
<fmt:formatNumber var="ff_version" value="${ ff ? fn:substringBefore(fn:substringAfter(ua, 'firefox/'), '.') : 0}" />
<c:set var="opera" value="${fn:contains(ua, 'opera')}" />
<fmt:formatNumber var="opera_version" value="${opera ?
@ceme
ceme / bash_curl_loop
Last active January 19, 2023 13:07
bash curl loop
while true; do sleep 1; curl http://www.google.com; echo -e '\n\n\n\n'$(date);done
@jshaw
jshaw / byobuCommands
Last active April 23, 2024 14:23
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@butlermh
butlermh / lucene4cosine.java
Created January 30, 2013 12:32
Using Lucene 4 to calculate cosine similarity
import java.io.IOException;
import java.util.*;
import java.util.Map;
import java.util.Set;
import org.apache.commons.math3.linear.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.document.*;
import org.apache.lucene.index.*;
import org.apache.lucene.store.*;
@andrewpthorp
andrewpthorp / Dispatcher.java
Created August 21, 2012 17:37
Java Ignore SSL Cert Errors
String url = "https://path/to/url/service";
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(url);
// Test whether to ignore cert errors
if (ignoreCertErrors){
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager(){
public X509Certificate[] getAcceptedIssuers(){ return null; }
public void checkClientTrusted(X509Certificate[] certs, String authType) {}