Skip to content

Instantly share code, notes, and snippets.

View AntonisFK's full-sized avatar
💭
Pushin 🅿️

Antonis AntonisFK

💭
Pushin 🅿️
  • Infuse
  • San Francisco
View GitHub Profile
# Set Paths
#-----------------------------------------------------------
export PATH="/usr/local/bin:$PATH"
export PATH="$HOME/bin:$PATH"
# Define system proxy connections to remote resources (predix)
#-------------------------------------------------------------
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
#include <iostream>
#include<string>
#include<vector>
#include<sstream>
using namespace std;
struct TokenFreq {
function permute(string) {
function recur(string, prefix) {
if (string.length === 0) {
console.log(prefix , "from if ")
return [prefix];
} else {
var out = [];
for (var i = 0; i < string.length; i++) {
var pre = string.substring(0, i);
var post = string.substring(i + 1);
@AntonisFK
AntonisFK / uploadFile.js
Created May 18, 2016 04:29
ng-upload controller
// this how a controller will look if your uploading multiple files
$scope.uploadFiles = function (files) {
$scope.files = files;
if (files && files.length) {
Upload.upload({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
data: {
files: files
}
@AntonisFK
AntonisFK / consecStr.js
Created May 4, 2016 07:37
given a string with only letters, return the start and end index of the largest consecutive letters
function check(str){
var word = str.split("");
var max = 0;
var arr1 = [];
var arr2 = [];
var letter = 0;
var counter = 0;
for(var i=0; i< word.length; i++){
if(word[letter] === word[i]){
@AntonisFK
AntonisFK / nthSll.js
Created April 28, 2016 02:32
Find the nth to last node in a linkedList
function nthtoLast (SLL, n){
if(SLL.head === null){
return -1;
}else{
var len = 0,
current = SLL.head;
while(current.next !== null){
current = current.next;
len ++ ;
@AntonisFK
AntonisFK / dupLinkedlist.js
Created April 28, 2016 00:21
Removing duplicates from an unsorted link list
function removeDuplicates(SSL){
if(this.head === null){
return false;
}else {
var current = this.head;
var obj = {};
while(current.next !== null){
// going to use an object to check if
if(current.next.value in obj){
//we are going to do the swap
@AntonisFK
AntonisFK / binarySearch.js
Created April 23, 2016 01:18
BinarySearch of an array
function binarySearch(array, key) {
var lo = 0,
hi = array.length - 1,
mid,
element;
while (lo <= hi) {
mid = Math.floor((lo + hi) / 2);
element = array[mid];
if (element < key) {
lo = mid + 1;
@AntonisFK
AntonisFK / rSigma.js
Created April 22, 2016 23:05
Write a recursive function that given a number returns sum of integers from 1 to that number. Example: rSigma(5) = 15 (1+2+3+4+5);
function rSigma (num){
if(num === 0){
return num;
} else {
return num + rSigma(num-1);
}
}
rSigma(5);
@AntonisFK
AntonisFK / isPalindrome.js
Created April 14, 2016 19:35
returns true if the string is a palindrome. Ignores empty spaces. Javascript
function isPalindrome(str){
var i=0,
j= str.length-1
while(i <j){
if(str[i] == " "){
i++;
}else if(str[j] ==" "){
j--;
}else {
if(str[i].toLowerCase() === str[j].toLowerCase()){