Skip to content

Instantly share code, notes, and snippets.

View isRuslan's full-sized avatar

Ruslan Ismagilov isRuslan

  • Yandex
  • Russia, Moscow
View GitHub Profile
@isRuslan
isRuslan / .ctags
Created February 1, 2017 07:53
crags options
--recurse=yes
--exclude=.git
--exclude=vendor/*
--exclude=node_modules/*
--exclude=db/*
--exclude=log/*
--exclude=.hg
--exclude=log
--exclude=tmp
@isRuslan
isRuslan / start_ctags.sh
Created February 1, 2017 07:44
generate ctags
#!/usr/bin/env bash
set -e
# ctags doesn't handle negative look behinds so instead this script
# strips false positives out of a tags file.
ctags "$@"
FILE="tags"
@isRuslan
isRuslan / The Technical Interview Cheat Sheet.md
Created December 21, 2016 21:17 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@isRuslan
isRuslan / Trie.py
Created December 14, 2016 20:52
Trie class example
import sys
class TrieNode:
def __init__(self, letter=None, count=0):
self.letter = letter
self.count = count
self.children = {}
self.is_leaf = False
class Trie:
@isRuslan
isRuslan / db.c
Created August 17, 2016 19:59
Single file database implementation in C
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define MAX_DATA 512
#define MAX_ROWS 100
struct Address {
@isRuslan
isRuslan / cp.c
Created August 17, 2016 19:45
cp(1) copy file1 to file2
#include <stdio.h>
#include <fcntl.h>
#include <stdarg.h>
#include <sys/syscall.h>
#define PERMS 0666
#define BUFSIZE 10000
void error(char *fmt, ...){
va_list args;
@isRuslan
isRuslan / diff.c
Created August 16, 2016 20:56
diff(1) first diff line
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#define MAXLINE 100
char *fgets(char *line, int maxline, FILE *fp);
void diff_line(char *a, char *b){
if(strcmp(a, b) < 0 || strcmp(a, b) > 0){
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX_SIZE 100000
int check_string(char s1[], char s2[]);
int main() {
bool findPairs(int arr[], int n)
{
// Create an empty Hash to store mapping from sum to
// pair indexes
map<int, pair<int, int> > Hash;
// Traverse through all possible pairs of arr[]
for (int i = 0; i < n; ++i)
{
for (int j = i + 1; j < n; ++j)
@isRuslan
isRuslan / index.js
Created July 6, 2015 22:27
JS: find one unique value from duplicate array
/*
Given the array of IDs, which contains many duplicate integers
and one unique integer, find the unique integer.
*/
// O(n^2): loop in loop
function find_unique_brute (array) {
var result = null, n = array.length;