Skip to content

Instantly share code, notes, and snippets.

View lsauer's full-sized avatar
🎯
Focusing

Lorenz Lo Sauer lsauer

🎯
Focusing
View GitHub Profile
@timbroder
timbroder / gist:1209944
Created September 11, 2011 18:32
insert update url rewrite
#INSERT INTO `core_url_rewrite` (`store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`)
SELECT 1 AS `store_id`,
`sub`.`category_id`,
`sub`.`entity_id` AS `product_id`,
CONCAT('product', '/', `entity_id`, '/', `category_id`) AS `id_path`,
`value` AS `request_path`,
CONCAT('catalog/product/view/id/', `entity_id`, '/category/', `category_id`) AS `target_path`,
1 AS `is_system`
FROM
(SELECT
@goldhand
goldhand / recursiveness
Created August 15, 2013 08:29
Things I learned dealing with JSON trees in django
# Things I learned dealing with recursive JSON objects
This is a summary of my findings while dealing with a django model, TaskCategory.
## Two ways for manipulating a set of trees
I found two different ways for manipulating objects with an uncertain amount
of ascendants / descendants. The first involves manipulating an object within
a tree and the second involves taking apart the tree, manipulating the branches
and building a new tree
@kzk
kzk / evhttp-multh-thread-httpd.cpp
Created November 6, 2010 13:53
Multi-Threaded HTTPServer using evhttp
#include <event.h>
#include <evhttp.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <iostream>
@dweldon
dweldon / install-docker.sh
Last active April 8, 2022 11:18
Install docker CE on Linux Mint 18.3
#!/usr/bin/env bash
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt-get update
sudo apt-get install docker-ce
# https://docs.docker.com/compose/install/
@edw
edw / heroku-pg-dump-schema.sh
Last active May 6, 2022 17:33
Dump a schema from a Heroku app's database.
#!/bin/sh
# Usage: heroku-pg-dump-schema.sh HEROKU-APP-NAME DB-ENV-VAR-NAME SCHEMA-NAME
app=$1
env_var=$2
schema=$3
db_url=`heroku config -s --app ${app} | grep ${env_var}`
@lsauer
lsauer / InChi.js
Created October 25, 2011 14:13
Regular Expressions for validating SMILES, InChi, InChiKey
// International Chemical Identifier Regex, by lo sauer - lsauer.com
// Morphine InchI:
var x="InChI=1S/C17H19NO3/c1-18-7-6-17-10-3-5-13(20)16(17)21-15-12(19)4-2-9(14(15)17)8-11(10)18/h2-5,10-11,13,16,19-20H,6-8H2,1H3/t10-,11+,13-,16-,17-/m0/s1"
// applying an organic character-subset
// we could check for the length property, but in case of 0 matches 'null' is returned -> hence !!.. \ generally equal to Boolean(..)
!!x.trim().match(/^((InChI=)?[^J][0-9BCOHNSOPrIFla+\-\(\)\\\/,pqbtmsih]{6,})$/ig)
>true
//generic:
x.trim().match(/^((InChI=)?[^J][0-9a-z+\-\(\)\\\/,]+)$/ig)
@kekru
kekru / 1-Enable Docker Remote API with TLS client verification.md
Last active January 11, 2024 18:21
Docker Remote API with client verification via daemon.json

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

@leandrosilva
leandrosilva / Client.cs
Created October 31, 2010 02:54
Asynchronous Client/Server Socket Example with C# (from MSDN library)
// Asynchronous Client Socket Example
// http://msdn.microsoft.com/en-us/library/bew39x2a.aspx
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
// State object for receiving data from remote device.
@soheilhy
soheilhy / nginxproxy.md
Last active March 22, 2024 08:54
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@gitaarik
gitaarik / git_submodules.md
Last active April 19, 2024 10:22
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.