Skip to content

Instantly share code, notes, and snippets.

@jampajeen
jampajeen / gist:d19f36a7309d0ead0e1f9735a26d66f3
Created January 12, 2021 15:35
Disable/Enable Mac OSX sleep on lid closed
# disable sleep
sudo pmset -b sleep 0; sudo pmset -b disablesleep 1
# re-enable sleep
sudo pmset -b sleep 5; sudo pmset -b disablesleep 0
@jampajeen
jampajeen / console-color.c
Created November 4, 2016 17:18
console text color
#include <stdio.h>
#include <cstdlib>
#define CLEAR "\x1b[2J" // clear
#define RESET "\x1b[0m" // reset color style
#define BLACK "\x1b[30m" /* Black */
#define RED "\x1b[31m" /* Red */
#define GREEN "\x1b[32m" /* Green */
#define YELLOW "\x1b[33m" /* Yellow */
@jampajeen
jampajeen / LC_CTYPE.txt
Created November 21, 2015 13:02
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@jampajeen
jampajeen / delete_unused_docker_images.sh
Created June 3, 2023 16:20
Delete unused docker images
docker rmi $(docker images -f "dangling=true" -q)
@jampajeen
jampajeen / nestjs-mongoose-uuid
Created June 3, 2020 13:57
Nestjs mongoose use UUID as an id
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { v4 as uuidv4 } from 'uuid';
@Schema()
export class Course extends Document {
@Prop({ type: String, default: function genUUID() {
return uuidv4()
}})
@jampajeen
jampajeen / nvidia-gt710-arm-pi-setup.sh
Created July 4, 2021 07:56 — forked from geerlingguy/nvidia-gt710-arm-pi-setup.sh
Set up the Nvidia GeForce GT 710 on Raspberry Pi Compute Module 4
#!/bin/bash
# Attempt to set up the Nvidia GeForce GT 710 on a Pi CM4.
#
# I have tried both armv7l and aarch64 versions of the proprietary driver, in
# addition to the nouveau open source driver (which needs to be compiled into
# a custom Raspberry Pi kernel).
#
# tl;dr - None of the drivers worked :P
@jampajeen
jampajeen / index.html
Created March 21, 2021 10:44 — forked from hpcslag/index.html
Image Recognize in Golang
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="/recognize" method="post" enctype="multipart/form-data">
@jampajeen
jampajeen / git-pushing-multiple.rst
Created February 20, 2021 13:13 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@jampajeen
jampajeen / go-call-c-lib
Created February 13, 2021 08:10
Golang call C function in dynamic library using dlopen
package cv
import "C"
import (
"log"
"github.com/rainycape/dl"
)
// Capture ...
@jampajeen
jampajeen / nats-cluster-healthcheck.yml
Created August 9, 2020 17:14
docker-compose nats steaming cluster healthcheck
healthcheck:
test: echo $$(wget --server-response http://node1:8222/varz 2>&1 | grep '200 OK') | grep '200' || exit 1
interval: 20s
timeout: 5s
retries: 5
start_period: 40s