Skip to content

Instantly share code, notes, and snippets.

View caroso1222's full-sized avatar

Carlos Roso caroso1222

View GitHub Profile
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@interactiveRob
interactiveRob / copy-to-clipboard-es6.js
Last active October 6, 2021 10:09
Copy String to Clipboard ES6 Method
copyToClipboard(str) {
/* ——— Derived from: https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
improved to add iOS device compatibility——— */
const el = document.createElement('textarea'); // Create a <textarea> element
let storeContentEditable = el.contentEditable;
let storeReadOnly = el.readOnly;
el.value = str; // Set its value to the string that you want copied
el.contentEditable = true;
@andyrbell
andyrbell / scanner.sh
Last active November 3, 2024 13:42
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@rkaramandi
rkaramandi / nginx-and-certbot-config.md
Last active June 25, 2024 13:23
Running NGINX and CertBot Containers on the Same Host

Running NGINX and CertBot Containers on the Same Host

The Problem

A lot of people run into the problem of running Let's Encrypt's CertBot Tool and an NGINX on the same container host. A big part of this has to do with CertBot needing either port 80 or 443 open for the tool to work as intended. This tends to conflict with NGINX as most people usually use port 80 (HTTP) or 443 (HTTPS) for their reverse proxy. Section 1 outlines how to configure NGINX to get this to work, and Section 2 is the Docker command to run CertBot.

1. NGINX Configuration

I use Docker Compose (docker-compose) for my NGINX server. My docker-compose.yml file looks something like this:

@drdrang
drdrang / Purge Old Reminders.scpt
Last active August 1, 2024 05:57
AppleScript to delete all reminders more than 30 days old.
set remindersOpen to application "Reminders" is running
set monthAgo to (current date) - (30 * days)
tell application "Reminders"
set myLists to name of every list
repeat with thisList in myLists
tell list thisList
delete (every reminder whose completion date is less than monthAgo)
end tell
end repeat
@mrgoos
mrgoos / app.module.ts
Last active September 17, 2024 21:54
Intercepting http request/respons in Angular 2. Works from version 2.3.0.
...
...
providers: [
{ provide: Http, useClass: ExtendedHttpService }
]
...
...
@mr-pinzhang
mr-pinzhang / angular2-example@dynamically-insert-template-into-component.ts
Last active November 1, 2017 20:42
An example to show the way of injecting template into Angular2 component dynamically
import { NgFor } from '@angular/common'
import { Component, QueryList, TemplateRef, ViewChild, ViewChildren, ViewContainerRef } from '@angular/core'
@Component({
directives: [
NgFor
],
selector: 'component',
template: `
<ul><li #item *ngFor="let number of list">{{number}}</li></ul>
@e0ipso
e0ipso / read-only-property-es6.js
Last active March 16, 2024 21:09
Read only property ES6
/**
* Class that holds a read only property.
*/
class PropertyBag {
/**
* Accessor.
*
* @return {string}
* The value. This annotation can be used for type hinting purposes.
@ankurk91
ankurk91 / npm-commands.md
Last active October 22, 2023 12:16
Useful npm commands and tricks

npm v3.10 - ◾

⚠️ This gist is outdated, but most of the commands are still relevant. ⚠️

Update npm itself

npm install -g npm
# Downgrade to a specific version
npm install -g npm@6