Skip to content

Instantly share code, notes, and snippets.

@jeherve
jeherve / plugin.php
Last active May 5, 2024 02:49
[Post Views For Jetpack] Display a Stats counter at the top of every post, with a "Views:" heading.
<?php
/**
* Display a Stats counter at the top of every post, with a "Views:" heading.
* @see https://wordpress.org/support/topic/page-views-off/
*
* @param string $content Post content.
*/
function jeherve_custom_display_post_views( $content ) {
$post_views = sprintf(
'<div class="stats_counter sd-content"><h3 class="sd-title">%1$s</h3><div class="sd-content">%2$s</div></div>',
@kashifulhaque
kashifulhaque / NvChad.md
Last active May 5, 2024 02:47
Neovim stuff with NvChad

Neovim keybinds

  • Capital letters do the opposite of small letters in command (Press shift to trigger capital letters)
  • _ (underscore) to move the cursor at the beginning of line (doesn't switch to insert mode)
    • 0 (zero) moves the cursor to the zeroth position of the line (doesn't switch to insert mode)
  • $ (dollar) to move the cursor at the end of line (doesn't switch to insert mode)
  • d$ will delete from wherever your cursor is till the end of the line
  • f<character> to move cursor to the first occurrence of <character>
    • f( to move cursor to first occurence of (
  • t<character> to move cursor to upto but not on the first occurrence of <character>
  • t( to move cursor to first occurence of (
@bwann
bwann / README.md
Last active May 5, 2024 02:47
Tunnelling SSH over SSL/TLS

How to tunnel SSH over SSL/TLS

laptop ssh -> laptop stunnel -> evil network -> internet -> your server -> your server ssh

Server (your shell server/home box/work box/whatever)

Sets up a stunnel process listening externally on port 2443/tcp, forwards to localhost 22/tcp

  • Install stunnel, e.g. yum install stunnel
  • Install server config snippet to /etc/stunnel/stunnel.conf
@Leandros
Leandros / random.h
Created July 2, 2018 05:22
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }
@nikolaydyankov
nikolaydyankov / firebase.ts
Last active May 5, 2024 02:33
Svelte x Firebase writable store
// Firestore
export function writableFirestoreStore<T>() {
let unsubscribe: () => void = () => {}
let docRef: any
const store = writable<T | null>(null)
let storeSet = store.set
return {
subscribe: store.subscribe,
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active May 5, 2024 02:28
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

@ejointjp
ejointjp / css.php
Created October 25, 2014 06:08
CSSをPHPで書く方法
<?php
//CSSとして使うPHPファイルの一番上に記述
header('Content-Type: text/css;', 'charset=utf-8'); ?>
@charset "utf-8";
<?php
//後はCSSを書く!
$bgcolor = 'pink';
?>
@UbadahJ
UbadahJ / FilterableListAdapter.kt
Last active May 5, 2024 02:25
A filterable ListAdapter for RecyclerView
abstract class FilterableListAdapter<T, VH : RecyclerView.ViewHolder>(
diffCallback: DiffUtil.ItemCallback<T>
) : ListAdapter<T, VH>(diffCallback), Filterable {
private var originalList: List<T> = currentList.toList()
override fun getFilter(): Filter {
return object : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults {
return FilterResults().apply {
@mkfares
mkfares / zsh-keyboard-shortucts.md
Last active May 5, 2024 02:22
Common zsh Keyboard Shortcuts on macOS Catalina

Common zsh Keyboard Shortcuts on macOS

Navigation

CTRL + A : Move the cursor to the beginning of the line
CTRL + E : Move the cursor to the end of the line
OPTION + Left Arrow : Move the cursor one word backward
OPTION + Right arrow : Move the cursor one word forward
Left Arrow : Move the cursor one character backward
Right Arrow : Move the cursor one character forward