Skip to content

Instantly share code, notes, and snippets.

View texpert's full-sized avatar

Aurel Branzeanu texpert

View GitHub Profile
@andrasbacsai
andrasbacsai / firewall.sh
Last active November 5, 2024 14:51
Update a Hetzner Firewall rule with your IP address
#!/bin/bash
# Script to update a firewall rule in a Hetzner Firewall with your current IP address.
# Good if you would like to restrict SSH access only for your current IP address (secure).
#################
# WARNING: This script will overwrite all rules in the firewall rules, so make sure you
# added all the required rules.
# I use a separate firewall rule just for SSH access.
#################
@ipanin
ipanin / mc_hotkeys.md
Created October 23, 2022 18:30
Midnight Commander Keyboard Shortcuts for macOS

Midnight Commander Keyboard Shortcuts for macOS

In macOS Meta key is Esc. In some other systems Meta key is Alt.

Ctrl

  • Ctrl-T - Select item (like Insert key in another OS).
  • Ctrl-Space - Calculate directory size.
  • Ctrl-O - Switch panels on/off.
  • Ctrl-U - Swap panels.
@starlinq
starlinq / cloud.mail.ru-webdav.md
Last active October 8, 2024 22:40
Подключение к Cloud.mail.ru с помощью WebDAV эмулятора в Убунту 18.04
title date
Подключение к Cloud.mail.ru с помощью WebDAV эмулятора в Убунту 18.04
2019-02-06

Подключение к Cloud.mail.ru с помощью WebDAV эмулятора в Убунту 18.04

Инструкцию для Убунту 20.04 см. здесь.

@shoogle
shoogle / qt-without-xcode.md
Last active August 13, 2024 09:48
Qt without XCode - how to use Qt Creator for macOS software development without installing XCode

Qt without Xcode

How to use Qt Creator for software development on macOS without having to install Xcode

Justification

Qt refuses to install on macOS unless Apple's Xcode is installed beforehand. This is unfortunate because:

@lvonk
lvonk / Cursor.rb
Last active July 7, 2024 12:20
Simple postgres cursor
# Use as
Cursor.new(Model.includes(foos: [:bar], :foo_bars).where(id < 1000000)).find_each do |model|
# do something
end
# Inspired by https://github.com/afair/postgresql_cursor
class Cursor
class NoopObserver
def close_failed(e)
end
@rkjha
rkjha / nginx-config-rails4-with-puma-ssl-version.conf
Last active November 2, 2023 11:57
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
# If there is no version tag in git this one will be used
VERSION = 0.1.0
# Need to discard STDERR so get path to NULL device
win32 {
NULL_DEVICE = NUL # Windows doesn't have /dev/null but has NUL
} else {
NULL_DEVICE = /dev/null
}
@Integralist
Integralist / Ruby Lambdas.md
Last active August 8, 2023 05:10
Ruby lambdas

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!
@davidbella
davidbella / person.rb
Created October 10, 2013 13:37
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active September 23, 2024 03:01
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: