Skip to content

Instantly share code, notes, and snippets.

@meskarune
meskarune / .tmux_theme
Last active April 10, 2021 21:35
simple tmux theme
set -g pane-active-border-bg default
set -g pane-active-border-fg "colour14"
set -g pane-border-fg "colour239"
set -g message-fg black
set -g message-bg "colour14"
set -g status-justify left
set -g status-bg "colour236"
set -g status-fg "colour14"
@tejacques
tejacques / HOCBaseRender.tsx
Last active May 2, 2022 13:05
React Higher Order Components in TypeScript
import * as React from 'react';
import { Component } from 'react';
export default function HOCBaseRender<Props, State, ComponentState>(
Comp: new() => Component<Props & State, ComponentState>) {
return class HOCBase extends Component<Props, State> {
render() {
return <Comp {...this.props} {...this.state}/>;
}
}
@Che4ter
Che4ter / mozoptimize
Created March 17, 2017 08:39
Bulk mozjpeg optimizer on the current directory, works with spaces in filename
#!/bin/bash
# Compresses all .jpg/.jpeg and saves them to opt/
# works with spaces in filenames
# make sure you adjust the path to mozjpeg bin
# uses the mozilla mozjpeg encoder from https://github.com/mozilla/mozjpeg
# based on https://gist.github.com/sauramirez/e0ef5059ab637ed3e2cea090b504f385
# Che4ter - 2017
#Change to mozjpeg path
MOZJPEG='/opt/mozjpeg/bin/'
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@cyan198
cyan198 / Readme.MD
Last active November 3, 2022 12:14
Setup WiFi with snap on Ubuntu Core

Connect to WiFi on Ubuntu Core using Snap

It was done on the following environment:

  • Raspberry Pi 3 Model B
  • OS: Ubuntu Core
  • Pi is connected to internet via Ethernet

Here are the overview of the steps:

@ievans
ievans / index.js
Created June 6, 2019 17:49
electron-native-notify-1.1.6 malicious source code
const MainProcessNotification = require("electron").Notification;
const isRenderer = process && process.type === "renderer";
const isSupported = () => isRenderer ? "Notification" in window : MainProcessNotification.isSupported();
const renderNotify = (title, body) => {
const notification = new Notification(title, {
body: body
});
return notification
};
try {
@cure53
cure53 / wasm.md
Last active October 17, 2023 00:16
Calling alert from WASM

Calling alert from WebAssembly (WASM)

This very simple and minimal tutorial documents in a few easy steps how to play with WebAssembly (WASM) and get first results within minutes.

While the code below is mostly useless, it will show, how to call the alert function from within a WASM file and thus demonstrate how to import and export DOM objects.

Of course, this exercise has no real use. It is just meant to show, that getting started with WASM isn't hard. And there is no need for a complex build-chain, tons of tools or a dedicated VMs. Just use a browser, one online tool and that's it.

And Now?

// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@gka
gka / make-animated-gifs-using-ffmpeg.md
Last active January 16, 2024 22:03
how to make a nice GIF from png frames

Make sure ffmpeg is up-to-date:

brew update
brew upgrade ffmpeg

Convert a MOV into frames. Tweak the 2/1 if you want more or fewer frames.

@scottyhq
scottyhq / merge-conflict-rebase.md
Created August 10, 2020 18:25
GitHub PR Merge Conflict Resolution with Rebase

How to rebase a pull request to fix merge conflicts

It's quite common to open up a pull request on GitHub and be confronted with the message This branch has conflicts that must be resolved. This situation arises when you create a feature branch on an older commit from the master branch. Maybe you forgot to run git pull master before git checkout -b geocoding_vignette or maybe a collaborator changed some of the same files on GitHub while you've been working on new things. There are many ways to fix this. One is using the Web Editor build into GitHub and fixing conflicts by hand. This works great if there are not too many conflicts.

Another technique is to rebase your pull request onto the master branch (Move your additional commits on top of the most recent master commit). This is conceptually clean, but sometimes confusing in practice to do cleanly. This example walks through the process where you want to do a rebase, and resolve conflicts by overwriting whatever is on the master branch with change