Skip to content

Instantly share code, notes, and snippets.

View gwuah's full-sized avatar
🎯
Focusing

Kwaw gwuah

🎯
Focusing
View GitHub Profile
@ZPascal
ZPascal / hoge.rb
Last active August 18, 2023 14:06 — forked from minamijoyo/hoge.rb
Using GitHubPrivateRepositoryReleaseDownloadStrategy removed in brew v2
require "formula"
require_relative "lib/private_strategy"
class Hoge < Formula
homepage "https://github.com/yourcompany/hoge"
url "https://github.com/yourcompany/hoge/releases/download/v0.1.0/hoge_v0.1.0_darwin_amd64.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
sha256 "6de411ff3e4b1658a413dd6181fcXXXXXXXXXXXXXXXXXXXX"
head "https://github.com/yourcompany/hoge.git"
version "0.1.0"
@ribice
ribice / caller.go
Last active July 7, 2023 07:07
A robust rabbitmq client for Go
go func() {
for {
err = rmq.Stream(cancelCtx)
if errors.Is(err, rabbitmq.ErrDisconnected) {
continue
}
break
}
}()
# (c) 2020 Humu
# MIT License
from typing import Any
import github
AUTOMERGE_LABEL_NAME = 'automerge'
@nitobuendia
nitobuendia / trailing_slash_middleware.py
Last active November 9, 2017 17:02
Django middleware that removes additional erroneous backslashes from your requests.
"""Middleware that removes additional meaningless backslashes.
This transforms URLs as follows:
- yourwebsite.com// to yourwebsite.com
- yourwebsite.com/section/// to yourwebsite.com/section
Ideally, this middleware should be placed before Commonmiddleware to avoid
conflicts with APPEND_SLASH. However, this code already appends final slash
if APPEND_SLASH is set to TRUE trying to reduce one additional redirect.
function dots(width, height, density) {
for (let i = 0; i < density; i += 1) {
createDot(
Math.floor(Math.random() * width),
Math.floor(Math.random() * height),
);
}
}
function createDot(x, y) {
@OmarShehata
OmarShehata / socket.js
Last active January 8, 2023 10:11
Socket.io simple cheat sheet
io.on('connection', function(socket){
/* 'connection' is a special event fired on the server when any new connection is made */
})
socket.on('disconnect', function(){
/* When this individual socket has disconnected, this special event fires */
})
/* This will send the event 'foobar' with the data to
every connected to socket */
@DariuszLuber
DariuszLuber / Webpack config for Sass+ES6+LiveReload.md
Last active July 29, 2022 10:10
Webpack + ES6 + Sass + Live reload

#Webpack + ES6 + Sass + Live reload

Basic example of webpack config to work with sass, es6 and live reload.

To get live reload working you need:

  • get package.json and webpack.config.js to your project foldee
  • run in terminal npm install
  • add this script <script src="http://localhost:35729/livereload.js"></script> to your index.html
  • create src folder and src files
  • run in terminal webpack
@JamoCA
JamoCA / Sanitize_Target_Blank.htm
Last active September 5, 2020 20:51
Use jQuery to automatically add noopener, noreferrer and nofollow to links w/target="_blank".
<cfcontent type="text/html; charset=UTF-8">
<!doctype html>
<html lang="en">
<head>
<title>Sanitize target="_blank"</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.slim.min.js" type="text/javascript"></script>
<script type="text/javascript">
/* 3/24/2017 Sanitize_Target_Blank.htm https://gist.github.com/JamoCA/80f65eb07f054b1326221bd4f15868d6 */
function sanitizeTargetBlank(){
$('#linkDiv a[rel~=external]').prop('target', '_blank');
@joepie91
joepie91 / express-server-side-rendering.md
Last active July 3, 2024 03:16
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti