Skip to content

Instantly share code, notes, and snippets.

View Star-Lord-XIII's full-sized avatar

Chintan Ghate Star-Lord-XIII

View GitHub Profile
@Star-Lord-XIII
Star-Lord-XIII / KMP.js
Last active September 20, 2015 17:27
Knuth–Morris–Pratt algorithm's javascript implementation in 123 characters.
p = "AABA" // pattern
t = "AABAACAADAABAAABAA" // text
m = p.length
n = t.length;
L = [];x=m;while(x--)L.push(0) // LPS array of size m, initialized to 0
e = []; // array to store ending indices of the pattern-match in the text
// Knuth–Morris–Pratt algorithm
for(i=1,l=0;i<m;)p[i]==p[l]?L[i++]=++l:l>0?l=L[l-1]:++i;for(i=j=0;i<n;++i)p[j]==t[i]?++j==m?e.push(i):0:j>0&&i--?j=L[j-1]:0
@Star-Lord-XIII
Star-Lord-XIII / SwiftInST3.md
Last active June 21, 2021 01:52
Running Swift scripts from Sublime Text 3 in MacOSX10.11

##Adding Swift Build System

  • Open Sublime Text 3
  • Go To Preferences > Browse Packages...
  • Add a file named Swift.sublime-build inside Packages directory.
  • Copy the following script in Swift.sublime-build file.
{
 	"shell_cmd": "xcrun swift $file",
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
@Star-Lord-XIII
Star-Lord-XIII / Default (OSX).sublime-keymap
Last active August 29, 2015 14:18
Restore old shortcuts for Single source files in Sublime Text 3 (cmd + b -> compile , cmd + shift + b -> run)
[
{
"keys": ["super+b"],
"command": "build",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.c++" }
],
"args": {
"build_system": "Packages/C++/C++.sublime-build",
"variant": "Build"