Skip to content

Instantly share code, notes, and snippets.


  • london
Block or report user

Report or block category

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Substring List Intersection

In [12]:  substrings = ['0012', '0013', '0007']
 strings = ['a0012', 'a0013', 'a0014', 'a0011', 'a006']

 [ e for e in substrings if reduce(lambda b1, b2: b1 or b2, list(map(lambda item: e in item, strings)))]

Out[14]: ['0012', '0013']
category /
Last active May 2, 2017
Supervisors in elixir

Supervisors in Elixir

Configure the worker spec

{:ok, pid} = Supervisor.start_link([Supervisor.Spec.worker(GenServerDB.Worker, [], [])], strategy: :simple_one_for_one)
Key Function Type Spec Notes
Supervisor.start_link/2 start_link([Supervisor.Spec.spec], options) :: on_start [Supervisor.Spec.spec] is usually just a list of workers or supervisors made using Supervisor.Spec.worker/3or Supervisor.Spec.supervisor/3. options need to at least include a strategy: option. To dynamically add workers at runtime, use the :simple_one_for_one strategy.
category / 0_reuse_code.js
Created Apr 13, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
category /
Last active Jul 24, 2017
msql - handy queries

Handy SQL Queries

Search for an SQL table

select table_name
from information_schema.tables
where table_name like '%tablenamesubstring%'

One liner

category /
Last active Apr 12, 2017
Add new service on Nagios XI GUI

On the Nagios XI GUI:

  1. Login
  2. Hover over the Configure heading on top horizontal toolbar
  3. Click Core Config Manager on the above dropdown
  4. On the left sidebar on the new page, click Services under the Monitoring dropdown menu
  5. Click Add New below the Services heading
category /
Last active Apr 11, 2017 - Configure stomp consumer to have a prefetch limit of 1

First of all configure the queue connection to have a prefetchSize of one:

self.connection.subscribe(destination=queueName, id=1, ack='client', headers={'consumer.prefetchSize': 1})

Then, pass the connection as an argument into the listener class and ack the message under the on_message method:

category /
Last active Apr 28, 2017
Lifesaver Git Commands

Remove file from git repo

check tracked files

git ls-tree --full-tree -r master

remove file from history

git filter-branch --tree-filter 'rm  file'

Replace tabs with spaces

C-x h # highlight/mark whole buffer
M-x untabify # replace tabs with spaces
M-x tabify # replace spaces with tabs


Display connected ipv4 sockets

ss -t4 state established

rsync file to remote box

You can’t perform that action at this time.