Skip to content

Instantly share code, notes, and snippets.

@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active Aug 14, 2020
How to copy production database on AWS RDS(postgresql) to local development database.
View how-to-copy-aws-rds-to-local.md
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
    • the database is restored
@kevinSuttle
kevinSuttle / meta-tags.md
Last active Aug 7, 2020 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@hgmnz
hgmnz / query_planner.markdown
Created Mar 23, 2011
PostgreSQL query plan and SQL performance notes
View query_planner.markdown

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.
@Grokzen
Grokzen / foo.py
Last active Jun 26, 2020
Symmetrical ManyToMany Filter Horizontal in Django Admin
View foo.py
# Based on post from: https://snipt.net/chrisdpratt/symmetrical-manytomany-filter-horizontal-in-django-admin/#L-26
# Only reposting to avoid loosing it.
"""
When adding a many-to-many (m2m) relationship in Django, you can use a nice filter-style multiple select widget to manage entries. However, Django only lets you edit the m2m relationship this way on the forward model. The only built-in method in Django to edit the reverse relationship in the admin is through an InlineModelAdmin.
Below is an example of how to create a filtered multiple select for the reverse relationship, so that editing entries is as easy as in the forward direction.
"""
### pizza/models.py ###
@briancroom
briancroom / Swift.md
Last active Mar 11, 2020
How to create a Swift modular library
View Swift.md

I am trying to determine if it is possible to build a Swift dynamic library which is itself composed of one of more private modules, without needing to expose to that fact to outside users. My hope was that I could build the private module as a static library, which would be linked into the primary (dynamic) library. The dylib could then be deployed together with its swiftmodule and swiftdoc and be imported, with the private module and its symbols not being exposed at all.

Unfortunately, what I'm currently observing seems to indicate that the private module's swiftmodule also has to be available for the primary library to be successfully imported.

This can be reproduced as follows. I have the following directory structure:

./Greeter/Logger/Logger.swift:

public func log(_ message: String) {
View verbatim_templatetag.py
"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.
Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best
@natecook1000
natecook1000 / NSTimer+Closure.swift
Last active Aug 1, 2019
Scheduled NSTimer with a Swift closure
View NSTimer+Closure.swift
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/
@marcoarment
marcoarment / encode-podcast.sh
Created Feb 13, 2015
Encode a podcast with metadata using command-line LAME
View encode-podcast.sh
#!/bin/bash
# Encode a WAV to a finalized podcast MP3 with metadata, in the current directory
# Requires lame
# With Homebrew on Mac OS X: brew install lame
SHOW_AUTHOR="ATP"
EPISODE_NUMBER=104
EPISODE_TITLE="Minutiæ"
@jiaaro
jiaaro / script.bash
Created Apr 24, 2013
Embed Python in a bash script
View script.bash
#!/bin/bash
export FOO=100
python - <<END
import os
print "foo:", os.environ['FOO']
END
You can’t perform that action at this time.