Skip to content

Instantly share code, notes, and snippets.

View andreasasprou's full-sized avatar

Andreas Asprou andreasasprou

View GitHub Profile
@reyjrar
reyjrar / elasticsearch.yml
Last active May 12, 2023 11:58
ElasticSearch config for a write-heavy cluster
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing
@jareware
jareware / SCSS.md
Last active April 23, 2024 22:13
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@andrewk
andrewk / form-validation.md
Created March 29, 2015 10:08
Good Enough™ Form Validation in React

Good Enough™ Form Validation in React

…specifically React 0.13 using ES6 class syntax

Originally I was implementing the validator as a context, but then I got stung by parent context vs owner context. I'll likely return to the context model when React's context implementation is more final (looks like they're moving towards parent context over owner context, which I'd prefer).

Requirements

  • markup must match our existing markup, for UX consistency.
  • inputs are re-usable components with an explicit contract -- they are responsponsible for their error display and any required filtering of their value.
@rvanbruggen
rvanbruggen / importtaxonomy.cql
Last active July 29, 2022 08:10
Google Product Taxonomy
//Import Google Product Taxonomy
//WITH IDENTIFIERS
//downloaded from https://support.google.com/merchants/answer/1705911
create index on :Cat1(name);
create index on :Cat2(name);
create index on :Cat3(name);
create index on :Cat4(name);
create index on :Cat5(name);
create index on :Cat6(name);
@burdandrei
burdandrei / CloudSearchExport.rb
Created November 17, 2015 15:02
Export all your data from CloudSearch and be free!
#!/usr/bin/env ruby
#
# Cloudsearch export script
#
# Required ENV Variables
# * AWS_ACCESS_KEY_ID
# * AWS_SECRET_ACCESS_KEY
# * CS_SEARCH_ENDPOINT
# * OUT_FILENAME
#
@eladnava
eladnava / mongodb-s3-backup.sh
Last active March 11, 2024 10:21
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
/**
* This script will automatically sync all updates from one database to another. It is meant to be run while
* syncing the database using mongodump and mongorestore.
*
* Example:
* node livesync.js mongodb://<user>:<pass>@dbhost.com:10645/app-production \
* mongodb://<user>:<pass>@dbhost.com:10499/local?authSource=app-production \
* app-production \
* mongodb://<user>:<pass>@newdbhost.com/app-prod
*/
@quadrismegistus
quadrismegistus / gensim_word2vec_procrustes_align.py
Last active November 16, 2023 01:57
Code for aligning two gensim word2vec models using Procrustes matrix alignment. Code ported from HistWords <https://github.com/williamleif/histwords> by William Hamilton <wleif@stanford.edu>. [NOTE: This code is DEPRECATED for latest versions of gensim. Please see instead this updated version of the code <https://gist.github.com/zhicongchen/9e23…
def smart_procrustes_align_gensim(base_embed, other_embed, words=None):
"""Procrustes align two gensim word2vec models (to allow for comparison between same word across models).
Code ported from HistWords <https://github.com/williamleif/histwords> by William Hamilton <wleif@stanford.edu>.
(With help from William. Thank you!)
First, intersect the vocabularies (see `intersection_align_gensim` documentation).
Then do the alignment on the other_embed model.
Replace the other_embed model's syn0 and syn0norm numpy matrices with the aligned version.
Return other_embed.
@caraboides
caraboides / backup-mongodb-to-s3.sh
Last active August 2, 2023 06:11
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH