Skip to content

Instantly share code, notes, and snippets.

category

  • 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
View substring_list_intersection.md

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
category / supervisors_in_elixir.md
Last active May 2, 2017
Supervisors in elixir
View supervisors_in_elixir.md

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
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
category / handy_mysql_queries.md
Last active Jul 24, 2017
msql - handy queries
View handy_mysql_queries.md

Handy SQL Queries

Search for an SQL table

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

One liner

@category
category / add_new_service_on_nagios_xi_gui.md
Last active Apr 12, 2017
Add new service on Nagios XI GUI
View add_new_service_on_nagios_xi_gui.md

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
category / stomp_prefetch_limit_of_one.md
Last active Apr 11, 2017
stomp.py - Configure stomp consumer to have a prefetch limit of 1
View stomp_prefetch_limit_of_one.md

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
category / lifesaver_git_commands.md
Last active Apr 28, 2017
Lifesaver Git Commands
View lifesaver_git_commands.md

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'
View replace_tabs_with_spaces_emacs.md

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
View centos_networking.md

#Networking

Display connected ipv4 sockets

ss -t4 state established

rsync file to remote box

You can’t perform that action at this time.