Skip to content

Instantly share code, notes, and snippets.

View sunnysingh's full-sized avatar

Sunny Singh sunnysingh

View GitHub Profile
@aweary
aweary / pr.sh
Created January 21, 2021 22:59
#!/bin/bash
set -e
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" = 'master' ]
then
echo You must check out a feature branch first
exit 1
fi
@m-radzikowski
m-radzikowski / script-template.sh
Last active October 9, 2025 00:41
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@riegl-aw
riegl-aw / docson-offline-tutorial.md
Last active March 4, 2023 03:23
Docson Offline Usage Tutorial

Docson Offline Usage Tutorial

This tutorial is about offline usage of the Docson JSON schema renderer.

Problem

The attempt to use Docson offline (i.e. not served by a web server) will result in a "Cross-Origin Request Blocked" error message when Docson loads the schema file:

Cross-Origin Request Blocked

import React from "react";
import { parse } from "url";
import PropTypes from "prop-types";
import Router from "next/router";
export default class LegacyPageWrapper extends React.Component {
static propTypes = {
backendHost: PropTypes.string,
pageContents: PropTypes.string,
allowFollowingLinkToLocation: PropTypes.func,
@naesheim
naesheim / buildWhenAffected.sh
Last active November 28, 2022 20:20
CircleCi - only build features that has changed
##################
### config.yml ###
##################
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6
steps:
// https://webreflection.medium.com/using-the-input-datetime-local-9503e7efdce
Date.prototype.toDatetimeLocal =
function toDatetimeLocal() {
var
date = this,
ten = function (i) {
return (i < 10 ? '0' : '') + i;
},
YYYY = date.getFullYear(),
MM = ten(date.getMonth() + 1),
@markerikson
markerikson / react-controlled-inputs.md
Last active June 15, 2021 12:50
React "controlled" vs "uncontrolled" inputs explanation

[12:03 AM] acemarke: "controlled" and "uncontrolled" inputs
[12:04 AM] acemarke: if I have a plain, normal HTML page, and I put <input id="myTextbox" type="text" /> in my page(edited)
[12:04 AM] acemarke: and I start typing into that textbox
[12:04 AM] acemarke: it remembers what I've typed. The browser stores the current value for that input
[12:05 AM] acemarke: and then sometime later, I can get the actual element, say, const input = document.getElementById("myTextbox"), and I can ask it for its value: const currentText = input.value;
[12:05 AM] acemarke: good so far?
[12:08 AM] acemarke: I'll keep going, and let me know if you have questions
[12:08 AM] lozio: ok, actually I'm reading
[12:09 AM] lozio: good
[12:09 AM] acemarke: so, a normal HTML input field effectively stores its own value at all times, and you can get the element and ask for its value

@dimasch
dimasch / redis-clear
Last active September 25, 2025 01:56
Clear a redis cache in Docker
docker exec -it container-name redis-cli FLUSHALL
var gulp = require('gulp');
var runSequence = require('run-sequence');
var minifyCss = require('gulp-minify-css');
var buildDir = './build/';
var build = new Date().getTime();
var minifyCssSettings = { advanced: true, aggressiveMerging: true };
// Main build
@noeldiaz
noeldiaz / gist:08a1211a7c47f21f7083
Created March 15, 2015 02:17
Nginx Multi-Site for Laravel
server {
listen 80;
server_name demo.example.com;
return 301 https://demo.example.com$request_uri;
}
server {
listen 443 ssl spdy;
server_name demo.example.com;
ssl on;