This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Search commands in history | |
set -e -u -o pipefail | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 wordToMatch anotherWordToMatch -skipIfWordMatches +wordToMatchCaseSensitive ..." | |
exit 1 | |
fi | |
command="cat ~/.bash_history" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -u -o pipefail | |
# Usage: Export a cookies.txt file from a browser logged-in in timeline.google.com with some | |
# add-on/extension (i.e. Export cookies, Get cookies.txt). Now run the script for the | |
# desired period: | |
# | |
# $ bash google-timeline-download.sh cookies.txt 2022-01-01 2022-02-20 out.kml | |
# | |
# Dependencies: curl, perl-xml-twig. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
require 'arel' | |
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
# | |
# What you would usually write like this: | |
# | |
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
# | |
# can now be written like this (note those parentheses required by the operators precedences): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const escapeXpathString = str => { | |
const splitedQuotes = str.replace(/'/g, `', "'", '`); | |
return `concat('${splitedQuotes}', '')`; | |
}; | |
const clickByText = async (page, text) => { | |
const escapedText = escapeXpathString(text); | |
const linkHandlers = await page.$x(`//a[contains(text(), ${escapedText})]`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionDispatch::Routing::Mapper | |
def localize_and_scope_for(locales, options = {}, &block) | |
scoped_locales = locales - Array(options[:skip_scope]) | |
localized(locales) do | |
locale_regexp = Regexp.new(scoped_locales.join('|')) | |
scope("/:i18n_locale", :constraints => {:i18n_locale => locale_regexp}) do | |
yield | |
end | |
yield if options[:skip_scope] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -u -o pipefail | |
run() { | |
for version in "$@"; do | |
local url="https://play.dhis2.org/$version/api" | |
echo "# $version" | |
curl -sS -u 'admin:district' -L "$url/events.json?event=QsAhMiZtnl2&fields=*" | jq >events.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* SelectedPick<T, Selector> | |
An extended version of Pick<T, Key> where, instead of a union of keys, | |
you pass an object with the properties to get from a type. */ | |
type Extends<T1, T2> = [T1] extends [T2] ? true : false | |
type OmitNever<T> = Pick<T, { [K in keyof T]: T[K] extends never ? never : K }[keyof T]> | |
export type Selector<Model> = { | |
[Key in keyof Model]?: boolean | NestedSelectorValue<Model[Key]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name rac1-alacarta | |
// @description Add back/forward buttons to audio player | |
// @namespace https://github.com/tokland | |
// @homepage https://github.com/cvzi/rollup-userscript-template | |
// @author tokland | |
// @match https://www.rac1.cat/a-la-carta* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=rac1.cat | |
// @run-at document-start | |
// @version 0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function escapeXpathString(str) { | |
const splitedQuotes = str.replace(/'/g, `', "'", '`); | |
return `concat('${splitedQuotes}', '')`; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
import urllib | |
from flask import Flask, Response, stream_with_context, request | |
app = Flask(__name__) | |
@app.route('/<path:url>', methods=["GET", "POST", "PUT", "DELETE"]) | |
def proxy(url): |
NewerOlder