Skip to content

Instantly share code, notes, and snippets.

View scicco's full-sized avatar

scicco

View GitHub Profile
@bszwej
bszwej / echo.js
Last active May 16, 2024 14:29
Pure Node.js echo server, that logs all incoming http requests (method, path, headers, body).
const http = require('http');
const server = http.createServer();
server.on('request', (request, response) => {
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
@soultech67
soultech67 / ruby_readline_issue.md
Last active June 6, 2022 21:18
ruby bundler: Sorry, you can't use byebug without Readline

Preamble

On OS/X Sierra, after recently running a brew update I started receiving the error message Sorry, you can't use byebug without Readline when trying to run some rake tasks in my ruby project folder. I observed this in projects and gems that include byebug or pry in their Gemfile or gem.spec. I've found in my googling that many begin encountering this error message after running a brew update but there are other triggering conditions as well.

>> rake aws:show_config
WARN: Unresolved specs during Gem::Specification.reset:
      mime-types (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
 Sorry, you can't use byebug without Readline. To solve this, you need to
@cschiewek
cschiewek / x11_docker_mac.md
Last active May 30, 2024 18:48
X11 in docker on macOS

To forward X11 from inside a docker container to a host running macOS

  1. Install XQuartz: https://www.xquartz.org/
  2. Launch XQuartz. Under the XQuartz menu, select Preferences
  3. Go to the security tab and ensure "Allow connections from network clients" is checked.
  4. Run xhost + ${hostname} to allow connections to the macOS host *
  5. Setup a HOSTNAME env var export HOSTNAME=`hostname`*
  6. Add the following to your docker-compose:
 environment:
@tekei
tekei / disable-ipv6.yml
Created February 27, 2016 14:31
ansible : (ubuntu) disable IPv6
---
- hosts: localhost
connection: local
become: yes
tasks:
- name: remove ipv6 hosts entry
shell: sed -i -e '/::/d' -e '/IPv6/d' /etc/hosts
- name: find ipv6 kernel parameter
shell: sysctl --all | egrep '^net.ipv6\..*disable' | awk '{print $1}'
register: ipv6_sysctl_list
@rashivkp
rashivkp / linkedin-icon-for-jekyll-footer.html
Last active June 21, 2022 06:00
linkedin svg icon for jekyll page footer
@drkarl
drkarl / gist:739a864b3275e901d317
Last active October 17, 2023 10:43
Ask HN: Best Linux server backup system?

Linux Backup Solutions

I've been looking for the best Linux backup system, and also reading lots of HN comments.

Instead of putting pros and cons of every backup system I'll just list some deal-breakers which would disqualify them.

Also I would like that you, the HN community, would add more deal breakers for these or other backup systems if you know some more and at the same time, if you have data to disprove some of the deal-breakers listed here (benchmarks, info about something being true for older releases but is fixed on newer releases), please share it so that I can edit this list accordingly.

  • It has a lot of management overhead and that's a problem if you don't have time for a full time backup administrator.
##Create a migration
### rails g migration make_unicode_friendly
class MakeUnicodeFriendly < ActiveRecord::Migration
def change
alter_database_and_tables_charsets "utf8", "utf8_general_ci"
end
private
def alter_database_and_tables_charsets charset = default_charset, collation = default_collation
@vitorbritto
vitorbritto / rm_mysql.md
Last active May 20, 2024 19:44
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql
    
@niyazpk
niyazpk / pQuery.js
Created October 25, 2014 14:03
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
@huskercane
huskercane / ruby_sffp_ssh_key.rb
Last active October 20, 2021 00:13
Use ruby net-sftp or net-ssh with private key authentication
require 'net/sftp'
SERVER = "127.0.0.0"
KEY_FILE = "/tmp/id_rsa"
Net::SFTP.start(SERVER, 'huskercane', :keys=>[KEY_FILE]) do |sftp|
sftp.mkdir! "/tmp/something"
#thats right needs full file name to copy
sftp.upload!("/tmp/something/something.txt", "/tmp/something/something.txt")
end