Skip to content

Instantly share code, notes, and snippets.

@renesugar
renesugar / ecto_postgres_fulltext_search_querying_example.ex
Created July 9, 2018 21:32 — forked from gvaughn/ecto_postgres_fulltext_search_querying_example.ex
How to set up postgres fulltext search triggers, index, and tsvector column on Elixir/Phoenix, with Ecto querying, including ranking and sorting by rank
defmodule YourAppName.Search do
# ...
@doc """
Queries listings.
"""
def query_listings(query, current_user) do
default_scope = from l in Listing, where: l.draft == false or l.user_id == ^current_user.id, order_by: [desc: l.updated_at], limit: 50
id = _try_integer(query)
@renesugar
renesugar / ecto_postgres_fulltext_search_querying_example.ex
Created July 9, 2018 22:51 — forked from pmarreck/ecto_postgres_fulltext_search_querying_example.ex
How to set up postgres fulltext search triggers, index, and tsvector column on Elixir/Phoenix, with Ecto querying, including ranking and sorting by rank
defmodule YourAppName.Search do
# ...
@doc """
Queries listings.
"""
def query_listings(query, current_user) do
default_scope = from l in Listing, where: l.draft == false or l.user_id == ^current_user.id, order_by: [desc: l.updated_at], limit: 50
id = _try_integer(query)
@renesugar
renesugar / aes.go
Created March 16, 2019 02:06 — forked from tscholl2/aes.go
simple AES encryption/decryption example with PBKDF2 key derivation in Go, Javascript, and Python
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"fmt"
"strings"
@renesugar
renesugar / webhook-mailer.php
Created April 25, 2019 22:31 — forked from jcanfield/webhook-mailer.php
Stripe Webhook PHP Example
<?php
// SETUP:
// 1. Customize all the settings (stripe api key, email settings, email text)
// 2. Put this code somewhere where it's accessible by a URL on your server.
// 3. Add the URL of that location to the settings at https://manage.stripe.com/#account/webhooks
// 4. Have fun!
// set your secret key: remember to change this to your live secret key in production
// see your keys here https://manage.stripe.com/account
@renesugar
renesugar / CopyableLabel.swift
Created June 15, 2019 02:20 — forked from zyrx/CopyableLabel.swift
Make UILabel Copyable in Swift 3. Special thanks to Stephen Radford and his "Make UILabel Copyable in Swift" article http://stephenradford.me/make-uilabel-copyable/
//
// CopyableLabel.swift
//
// Created by Lech H. Conde on 01/11/16.
// Copyright © 2016 Mavels Software & Consulting. All rights reserved.
//
import UIKit
class CopyableLabel: UILabel {
@renesugar
renesugar / emlToMbox.py
Created April 7, 2020 23:53 — forked from kadin2048/emlToMbox.py
Combine a directory of .eml files into a single Unix "mbox" file.
#!/usr/bin/env python
""" Converts a directory full of .eml files to a single Unix "mbox" file.
Accepts as input either an individual .eml file or a directory containing one
or more .eml files.
The output mbox will be created if it doesn't already exist. If it exists,
it will be appended to. There is no checking for duplicates, so use caution.
If duplicate filtering is desired, it could be added to addFileToMbox().
@renesugar
renesugar / .gitignore
Created April 7, 2020 23:54 — forked from foxmask/.gitignore
Parsing Evernote export file (.enex) using Python
*.enex
@renesugar
renesugar / mynote.xml
Created April 7, 2020 23:55 — forked from xiaoganghan/mynote.xml
Parsing Evernote export file (.enex) using Python
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export2.dtd">
<en-export export-date="20120727T073610Z" application="Evernote" version="Evernote Mac 3.0.5 (209942)">
<note><title>Vim Tips</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
yank for copy, delete for cut, put for parse
<div><br/></div>
<div>Move in context, not position</div>
<div>/ search forward</div>