Skip to content

Instantly share code, notes, and snippets.

Avatar

Tasos Soukoulis taosx

View GitHub Profile
View interview-questions.md

Interview Preparation

Created: Mar 19, 2020 4:37 PM Tags: Golang, Linux

When using an empty struct?

  • When you want to save some memory.
  • When implementing a data set.
  • When writing a seen hash
View test_nc_ins.xml
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="https://www.w3.org/2005/Atom" xmlns:dc="https://purl.org/dc/elements/1.1/"
xmlns:content="https://purl.org/rss/1.0/modules/content" xmlns:newsmail="//">
<channel>
<title>Daily Insider Newsletter</title>
<link>https://eprod.ncinsider.com/site-services/newsletters/daily-insider-newsletter/</link>
<atom:link href="https://eprod.ncinsider.com/feeds/fulltext/newsletter/daily-insider-newsletter" rel="self" type="application/rss+xml"></atom:link>
<description>Daily Insider Newsletter from the The Insider North Carolina State Government News Service newspaper in The Triangle.</description>
<language>en</language>
View decoding into class.py
from typing import Optional, List, Any
from marshmallow import Schema, fields, pprint
class Structure(object):
_fields = []
def _init_arg(self, expected_type, value):
if isinstance(value, expected_type):
return value
View background-slider.jsx
import React, { Component, useState, useEffect, useRef } from "react"
import BackgroundImage from "gatsby-background-image"
import style from "./index.module.css"
// props: data.allFile.edges[].node.childImageSharp.fluid
class BackgroundSliderMain extends Component {
state = {
current: 0,
edgeIndex: 0,
View asd821sa.js
function FindProxyForURL(url, host) {
host = host.toLowerCase();
if (shExpMatch(host, "*.nandomedia.com") || shExpMatch(host, "*.adobe.com")){
return "SOCKS 127.0.0.1:1337"; // (IP:port)
}
return "default";
}
@taosx
taosx / psql_migration.re
Created Mar 11, 2019
How you could improve this code?
View psql_migration.re
let getMigrations: string => array(string) =
migrationsPath => Node.Fs.readdirSync(migrationsPath);
let readContent: string => string =
migrationFilePath => Node.Fs.readFileAsUtf8Sync(migrationFilePath);
let handleError = Js.String.make;
let countMigrations:
Postgres.client => Js.Promise.t(Belt.Result.t(int, Js.Promise.error)) =
View db_state_knex.re
type badStates =
| ECONNREFUSED /* database not running, or running on different port */
| SHUTTING_DOWN
| STARTING_UP
| ERROR(string);
let db_state = xs => (
Js.String.includes("ECONNREFUSED", xs),
Js.String.includes("is shutting down", xs),
@taosx
taosx / gist:07de1e5b1134e9d572294914b004f7a2
Created Mar 13, 2018
Keywords of techniques, algorithms that may be helpful.
@taosx
taosx / mysql_wait.sh
Created Jun 8, 2017
Wait for mysql connection
View mysql_wait.sh
#https://stackoverflow.com/a/37300565
until nc -z -v -w30 $MYSQL_HOST 3306
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
View OpenResty Build Arguments
--with-file-aio \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \