Skip to content

Instantly share code, notes, and snippets.

@mgaitan
mgaitan / git-sw
Last active April 30, 2024 13:36
git smart switch : Like `git switch` but stashing uncommitted changes and recovering them when you are back.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Git smart switch
Like `git switch` but stashing uncommitted changes and recovering them when you are back.
# Install

A metatable can be defined like

local t = setmetatable({}, {
  __tostring = function() return 'custom tostring behavior!' end
})

Here are the metamethods that you can define, and their behavior

Operators

@JamesTheHacker
JamesTheHacker / Session.js
Last active April 30, 2024 13:33
Log into Facebook using cookies
'use strict'
let Promise = require('bluebird');
let fs = Promise.promisifyAll(require('fs'));
let Cheerio = require('cheerio');
let Request = require('request');
let ToughCookie = require('tough-cookie');
class Session {
@SheldonWangRJT
SheldonWangRJT / Convert .mov or .MP4 to .gif.md
Last active April 30, 2024 13:33
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@cayter
cayter / repository.ts
Last active April 30, 2024 13:32
Drizzle ORM Type-Safe Repository With PgTable
import { startSpan } from "@sentry/remix";
import type { StartSpanOptions } from "@sentry/types";
import {
type AnyColumn,
type AnyTable,
type BuildQueryResult,
type DBQueryConfig,
type DrizzleTypeError,
type Equal,
type ExtractTablesWithRelations,
@codeadamca
codeadamca / mamp-php-versions.md
Last active April 30, 2024 13:32
How to add new PHP versions to MAMP on a Mac

Adding Versions of PHP to MAMP on a Mac

If you're working on a project that requires a version of PHP higher than the versions that MAMP comes with, you can easily add additional verions.

My version of MAMP came installed with PHP 7.4.21 and 8.0.8. I'm attempting to use MAMP to host a Laravel application which requires at least PHP 8.1.

The version of PHP MAMP uses is often different than the version you have installed. I have installed PHP using Brew. I'm currently running PHP 8.1.8. If you want to check your installed version of PHP, use the terminal and run the following command:

php --version
@thesamesam
thesamesam / xz-backdoor.md
Last active April 30, 2024 13:31
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Background

On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that

@Phlow
Phlow / for-loop-sorted-collection
Last active April 30, 2024 13:30
This Liquid loop for Jekyll sorts a collection by date in reverse order
{% comment %}
*
* This loop loops through a collection called `collection_name`
* and sorts it by the front matter variable `date` and than filters
* the collection with `reverse` in reverse order
*
* To make it work you first have to assign the data to a new string
* called `sorted`.
*
{% endcomment %}
function Find-VisualStudio() {
Write-Information "Finding VisualStudio .exe path"
$vsWherePath = join-path ${env:ProgramFiles(x86)} "\Microsoft Visual Studio\Installer\vswhere.exe"
Write-Debug "Checking for vswhere.exe at $vsWherePath"
if (-not (Test-Path $vsWherePath)) {
Write-Error "vswhere.exe not found at $vsWherePath"
exit 1
}
Write-Debug "Finding VisualStudio Installation Location using:"