Skip to content

Instantly share code, notes, and snippets.

View lovasoa's full-sized avatar
🎯
Focusing

Ophir LOJKINE lovasoa

🎯
Focusing
View GitHub Profile
@lovasoa
lovasoa / server.js
Created June 14, 2018 12:30
Small node server to help testing how a client handles invalid or conflicting encodings. Launch it, then visit http://localhost:8000/?responseText=héhé&htmlCharset=iso-8859-1&headerCharset=windows-1251
var http = require('http');
var uparse = require('url').parse;
http.createServer(function ({url}, res) {
const {headerCharset, responseText, htmlCharset} = uparse(url, true).query;
const ctype = 'text/html' + (headerCharset ? '; charset=' + headerCharset : '');
res.writeHead(200, {'Content-Type': ctype});
const meta = htmlCharset ? `<meta charset="${htmlCharset}">` : ``;
res.end(`<!doctype html>
<html>
import Data.Maybe
import Data.List
import Data.Ord
data DicTrie = DicTrie [(Char, DicTrie)] deriving Show
emptyTrie = DicTrie []
mainDict = DicTrie [
('e', DicTrie[
('n', DicTrie[
@lovasoa
lovasoa / voc_sequencer.py
Created June 8, 2018 14:22
Create a vocabulary list
#!/usr/bin/env python3
from collections import Counter
import numpy as np
import pickle
MAX_COUNTER_SIZE = 2**16
MAX_SEQ_SIZE = 16
MAX_SIMILARITY = .75
#!/usr/bin/env python3
import pandas as pd
import numpy as np
import sys
import logging
def is_valid_line(line: bytes):
return line and b"SQLProxy" not in line and b"P2_COD" not in line
#version: 0.2
e s</w>
d e</w>
e n
a n
o n
t i
l e</w>
o u
e s
CREATE TABLE SUBJECT1 (
NAME VARCHAR(100),
SURNAME VARCHAR(100),
CITY VARCHAR(100)
);
INSERT INTO SUBJECT1
SELECT NAME, SURNAME, CITY
FROM SUBJECT
GROUP BY NAME, SURNAME, CITY;
package com.qwant.debouncer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
-- Employees and departments
CREATE TABLE EMPLOYEES(ID INTEGER, NAME VARCHAR, CHIEF_ID INTEGER, SALARY INTEGER, DEPARTMENT_ID INTEGER);
CREATE TABLE DEPARTMENTS(ID INTEGER, NAME VARCHAR);
INSERT INTO DEPARTMENTS VALUES (1, "DEP 1"), (2, "DEP 2"), (3, "DEP 3");
INSERT INTO EMPLOYEES VALUES
(1,"Աշոտ",2,3000,1),
(2,"Ophir",NULL,2500,1),
(3,"Армен",1,4000,2);
#include <iostream>
using namespace std;
bool in(int x, int y, int x1, int x2, int y1, int y2){
return x1<=x && x<=x2
&& y1<=y && y<=y2;
}
int main()
{
@lovasoa
lovasoa / base2_add.cpp
Created April 18, 2018 15:05
Read and write numbers in base 2
#include<iostream>
using namespace std;
unsigned int read_base2() {
int n=0; char c;
for(cin.get(c); c=='0'||c=='1'; cin.get(c)) n = (n<<1)|(c-'0');
return n;
}
void write_base2(unsigned int n, bool first=true) {