Skip to content

Instantly share code, notes, and snippets.

@bobbybouwmann
bobbybouwmann / User.php
Last active May 18, 2024 16:05
Laravel Absolute vs Relative Dates with Carbon
<?php
namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
@belenaj
belenaj / sipsRaw2Jpeg.md
Last active May 18, 2024 16:04
Convert RAW photos to JPG in the Mac OS terminal

Convert RAW photos to JPG in the Mac OS terminal

Source: https://coderwall.com/p/nhp7mq/convert-raw-photos-to-jpg-in-the-mac-os-terminal

No need for slow and heavy Photoshop scripts for this one, you can do easily do this right from your terminal window.

This is possible using "sips", an image editing tool already available on Mac which allows you to do all sorts of image manipulation, including resizing and converting.

So we first grab all RAW files in a folder, We convert them to jpeg (or any other format),

@zentala
zentala / formatBytes.js
Created September 27, 2017 11:57
Convert size in bytes to human readable format (JavaScript)
function formatBytes(bytes,decimals) {
if(bytes == 0) return '0 Bytes';
var k = 1024,
dm = decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
// Usage:
MOSDNS v5 配置
@GerardoLopez
GerardoLopez / save_xarray_to_gtiff.py
Created February 23, 2021 11:04
Save xarray to a Cloud Optimized GeoTIFF (COG)
import gdal
from osgeo import gdal_array
import osr
import numpy
def get_dst_dataset(dst_img, cols, rows, layers, dtype, proj, gt):
"""
Create a GDAL data set in Cloud Optimized GeoTIFF (COG) format
:param dst_img: Output filenane full path
@williamyang98
williamyang98 / calculate_chebyshev_sine_polynomial_gradient_descent.cpp
Last active May 18, 2024 15:54
Calculate chebyshev polynomial that will approximate f(x) = sin(kx). where k = π/root. Uses gradient descent.
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <cmath>
#include <vector>
#include <random>
static bool is_running = true;
#if _WIN32
#define WIN32_LEAN_AND_MEAN
@kepano
kepano / obsidian-web-clipper.js
Last active May 18, 2024 15:54
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 18, 2024 15:53
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@patmigliaccio
patmigliaccio / install-cf-gae-ssl.md
Last active May 18, 2024 15:53
Configuring Cloudflare SSL/TLS certificates on Google App Engine

Configuring Cloudflare SSL/TLS on Google App Engine

Implementing end-to-end HTTPS encryption with CloudFlare for Google App Engine applications.

Google App Engine - Custom Domains

Add Domains

Register the root domain with Google Cloud Platform at the following: