Skip to content

Instantly share code, notes, and snippets.

@inexorabletash
inexorabletash / @ IndexedDB Full Text Search (Proof of Concept).md
Last active March 19, 2024 13:08
IndexedDB Full Text Search (Proof of Concept)

This demonstrates the implementation of full text search for documents in Indexed DB.

  • Word-breaking and stemming is used to create a list of terms for each document.
  • Document records are annotated with the list of terms when added to the database.
  • A multi-entry index on the list of terms is populated.
  • A query is similarly processed into a list of terms.
  • A join over the terms is implemented using multiple cursors on the index.

The necessity of annotating records with the word list to populate the index is a limitation of the current Indexed DB API. A feature request to support custom

//
// Signal+Extensions.swift
// Khan Academy
//
// Created by Nacho Soto on 10/1/15.
// Copyright © 2015 Khan Academy. All rights reserved.
//
import ReactiveCocoa
@feighter09
feighter09 / Fonts.swift
Last active June 25, 2021 19:24
Set global font for iOS app in one place
// MARK: - Swizzling
extension UIFont {
class var defaultFontFamily: String { return "Georgia" }
override public class func initialize()
{
if self == UIFont.self {
swizzleSystemFont()
}
}
@a-know
a-know / README.md
Last active October 13, 2022 07:03
!! Deprecated !! - Get and Show cell's value from Google Spreadsheet Widget for Dashing

Description

Get and Show cell's value from Google Spreadsheet Widget for Dashing.

Dependency

  • gem 'google-api-client'
  • gem 'google_drive'

Installation

dashing install e0ad37c2e137d2da0916

@Kimtaro
Kimtaro / gist:ab137870ad4a385b2d79
Created December 26, 2014 12:06
Add to mecab dictionary
# Put new words in a CSV with this format
# 表層形,左文脈ID,右文脈ID,コスト,品詞,品詞細分類1,品詞細分類2,品詞細分類3,活用形,活用型,原形,読み,発音
# surface_form,left_context_id,right_context_id,cost,part_of_speech,pos_division_1,pos_division_2,pos_division_3,inflection_type,inflection_style,lemma,reading,pronunciation
$ echo "fasihsignal,-1,-1,100,名詞,一般,*,*,*,*,fasihsignal,ファシシグナル,ファシシグナル" > a.csv
# Then use mecab-dict-index to compile the csv into a .dic file, based on an existing mecab dictionary file
$ /usr/local/Cellar/mecab/0.996/libexec/mecab/mecab-dict-index -d/usr/local/Cellar/mecab/0.996/lib/mecab/dic/ipadic/ -u a.dic -f utf8 -t utf8 a.csv
# The use it
$ mecab -ua.dic
@joshjdevl
joshjdevl / gist:26ddf5f5e8d9e495c87b
Last active August 29, 2015 14:02 — forked from shawnburke/gist:3750709
ubuntu ec2 bash prompt instance tag name
# these make the ec2 commands just work
export AWS_ACCESS_KEY=[AWS access key]
export AWS_SECRET_KEY=[AWS secret]
# fetch the instance id
export INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
#grep out the tag you're looking for, in this case "Name"
export APP_TAG=$(ec2dtag --region us-west-2 --filter "key=Name" --filter "resource-type=instance" --filter "resource-id=$INSTANCE_ID" | grep -oE "Name\\W+(.+)$" | grep -oE "\\W.+$")
@tristanfisher
tristanfisher / Ansible-Vault how-to.md
Last active April 3, 2024 13:55
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

Working with ansible-vault


I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@bunnyhero
bunnyhero / ReusableCellExample.m
Last active February 19, 2022 02:04
Example of Reactive Cocoa binding for a reusable cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:REUSABLE_CELL_ID];
UILabel *label = (UILabel *)[cell viewWithTag:VIEW_TAG];
Model *someModel = [self getModelFromIndexPath:indexPath];
// `takeUntil:` makes the RACObserve() signal complete (and thus breaks the subscription)
// when the cell is recycled.
@lukeredpath
lukeredpath / UITextField+RACKeyboardSupport.m
Last active April 19, 2017 10:36
ReactiveCocoa signal for keyboard done button taps
#import "UITextField+RACKeyboardSupport.h"
#import <ReactiveCocoa/RACEXTScope.h>
#import <ReactiveCocoa/NSObject+RACDescription.h>
@implementation UITextField (RACKeyboardSupport)
- (RACSignal *)rac_keyboardReturnSignal {
@weakify(self);
return [[[[RACSignal
defer:^{
@artemrizhov
artemrizhov / south_multidb.py
Created October 30, 2013 15:49
This adds multiple databases support to South. Import the module in your migration. Set `database` attribute on your migration class to the alias of db that you want to use. Access the database api via self.db.
from south import db as db_module
from south.migration.migrators import Migrator, DryRunMigrator
def with_db(run_migration):
def run_migration_with_db(self, migration, database):
migration_db = getattr(migration._migration.Migration,
'database', None)
if migration_db is not None: