Skip to content

Instantly share code, notes, and snippets.

#![warn(rust_2018_idioms)]
#[derive(Debug)]
pub struct StrSplit<'haystack, D> {
remainder: Option<&'haystack str>,
delimiter: D,
}
impl<'haystack, D> StrSplit<'haystack, D> {
pub fn new(haystack: &'haystack str, delimiter: D) -> Self {
@borkdude
borkdude / call_rust_from_c.sh
Last active March 6, 2020 22:46
Call a Rust function from C
#!/usr/bin/env bash
rustc --crate-type=dylib hello.rs
gcc hello.c -o hello
./hello # Just called a Rust function from C!
@IanColdwater
IanColdwater / twittermute.txt
Last active October 13, 2024 04:40
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@yogthos
yogthos / gallery.cljs
Last active March 30, 2024 17:36
script to download walpapers from windowsonearth.org
@lukecav
lukecav / php.ini
Last active November 25, 2023 07:26
OPCache Options for WordPress
opcache.enable=1
opcache.memory_consumption=192
opcache.max_wasted_percentage=5
opcache.max_accelerated_files=7963
opcache.revalidate_freq=5
opcache.interned_strings_buffer=16
opcache.save_comments=1
opcache.load_comments=1
opcache.enable_file_override=0
opcache.fast_shutdown=1
@mfikes
mfikes / iml.md
Last active January 5, 2020 22:31
Implicit Macro Loading

ClojureScript macros can be loaded using the :require-macros primitive in ns forms (or require-macros REPL special).

But, there is a shortcut you can take if a runtime namespace requires macros from its macro namepace file. This might be a bit tricky to understand so here is a concrete example.

Let's say you have a macro file:

$ cat src/foo/core.clj
(ns foo.core)
@zpratt
zpratt / complete-custom-overlay.js
Created March 29, 2015 06:16
Complete Custom Overlay
'use strict';
var google = global.google;
function positionOverlayByDimensions(projectedLatLng) {
var offsetHeight = this.el.offsetHeight,
offsetWidth = this.el.offsetWidth;
this.el.style.top = projectedLatLng.y - offsetHeight + 'px';
this.el.style.left = projectedLatLng.x - Math.floor(offsetWidth / 2) + 'px';
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 14, 2024 09:13
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'