Skip to content

Instantly share code, notes, and snippets.

View cromat's full-sized avatar

Tomislav Brabec cromat

View GitHub Profile
@jmwhittaker
jmwhittaker / Localhost in VMWare VM
Created March 14, 2011 15:22
Get localhost working in VMWare
Connect to your Mac's localhost from within a VMWare virtual machine.
- Boot up VMware and fire up your VM (i'm using Windows 7)
- Make sure that the VM is using NAT
- Fire up the command prompt in Windows and type "ipconfig". IN the resulting text look for your IPv4 address. It will be something like 192.168.xxx.xxx
- Now go to your browser in your VM and type that ip address into the url bar but change the last set of digits to be 2 (or 1).
- so as an example if your ip was found to be 192.168.213.200 change it to be 192.168.213.2
- Assuming that your localhost is running on your mac you should get your localhost in your VM browser.
- If you need to add a non standard port number on the end like 8090 go ahead and do so.
the easiest way to use multiple constructors:
<?php
class A
{
function __construct()
{
$a = func_get_args();
$i = func_num_args();
if (method_exists($this,$f='__construct'.$i)) {
@cassus
cassus / admin.py
Last active September 28, 2022 18:15
Django admin action as row button
class MyAdmin(admin.ModelAdmin):
list_display = (..., 'actions_html')
def actions_html(self, obj):
return format_html('<button class="btn" type="button" onclick="activate_and_send_email({pk})">Activate and send email</button>', pk=obj.pk)
actions_html.allow_tags = True
actions_html.short_description = "Actions"
@staltz
staltz / introrx.md
Last active April 18, 2024 15:33
The introduction to Reactive Programming you've been missing
@apollolm
apollolm / nginx-ssl-config
Last active January 12, 2023 14:47
Nginx Configuration with multiple port apps on same domain, with SSL.
# the IP(s) on which your node server is running. I chose port 3000.
upstream app_geoforce {
server 127.0.0.1:3000;
}
upstream app_pcodes{
server 127.0.0.1:3001;
}
@notheotherben
notheotherben / README.md
Last active September 9, 2021 07:50
Fix Postgres 9.x Sequences

PostgreSQL 9.x Sequence Fixing Script

This script is intended to automatically fix the sequence numbers for all tables in the current database.

This is accomplished through the use of the setval() command, which we provide with the next ID value we wish to make use of. We use the setval(sequence, number, is_called) overload and set is_called = false in conjunction with COALESCE(MAX + 1, 1) to ensure that, with an empty table, the next sequence value is 1 as expected.

@pcan
pcan / README.md
Created April 3, 2017 09:16
Compile Redis with Cygwin

Prerequisites

Install Cygwin with make, gcc & g++. Download Redis tar.gz package, unpack it.

Patch

Edit deps/hiredis/net.c and add the following lines just after the include directives:

@dentechy
dentechy / WSL-ssh-server.md
Last active March 30, 2024 16:16
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@gunnarx
gunnarx / gist:527fbc385a2e76f89609d837b6447f85
Last active November 18, 2022 06:08
Docker to Virtualbox