Skip to content

Instantly share code, notes, and snippets.

View trajche's full-sized avatar
🍕
Hungry

Trajche TJ Kralev trajche

🍕
Hungry
  • Helsinki, Finland
View GitHub Profile
@nileshtrivedi
nileshtrivedi / home-server.md
Last active January 10, 2024 06:30
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

@exocode
exocode / xfs-on-hetzner.yml
Last active January 27, 2024 06:33
Create xfs partitions on Hetzner via cloud-init. It keeps root disk available again after rebooting. Simply change your desired sizes and filesystem to use it for your needs.
#cloud-config
resize_rootfs: false
disk_setup:
/dev/sda:
table_type: 'mbr'
layout:
- 25
- 75
overwrite: true
@Chrisedmo
Chrisedmo / Craft3ValetDriver.php
Created February 1, 2017 10:29
Craft 3 Composer Install Valet Driver
<?php
class Craft3ValetDriver extends ValetDriver
/* https://github.com/laravel/valet/blob/master/cli/drivers/CraftValetDriver.php */
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
@friartuck6000
friartuck6000 / acf-field-group-schema.json
Created April 12, 2016 18:34
JSON schema for Advanced Custom Fields (ACF) field groups
{
"$schema": "http://json-schema.org/schema#",
"id": "http://advancedcustomfields.com/json-schema/field_group",
"type": "object",
"definitions": {
"empty": {
"type": "string",
"maxLength": 0
},
"intOrEmpty": {
<?php
date_default_timezone_set('UTC');
$foo = '{"bar":{"$date":1358205756553},"pop":{"goes":{"err":{"$binary":"c3VyZS4="},"the":{"weasel":{"$date":1358205756553,"$tz":"America/New_York"}}}}}';
class EJSON {
protected static $customTypes = [];
public static function type($marker, $decoder) {
if (!is_callable($decoder)) {
@WebEndevSnippets
WebEndevSnippets / functions.php
Created March 3, 2014 19:50
Gravity Forms: Auto login to site after GF User Registration Form Submittal
add_action( 'gform_user_registered','we_autologin_gfregistration', 10, 4 );
/**
* Auto login to site after GF User Registration Form Submittal
*
*/
function we_autologin_gfregistration( $user_id, $config, $entry, $password ) {
wp_set_auth_cookie( $user_id, false, '' );
}
@aahan
aahan / WordPress Custom Global Variables.md
Last active March 28, 2024 19:26
Creating and using custom global variables in wordpress.

First create global variables (in functions.php or as a mu-plugin):

<?php

/*
 * CUSTOM GLOBAL VARIABLES
 */
function wtnerd_global_vars() {
@jonschlinkert
jonschlinkert / starter-template.html
Created November 21, 2012 05:23
bootstrap starter template with cdn assets
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Starter Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- styles -->
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@1stvamp
1stvamp / mac-curl-ca-bundle.sh
Created March 22, 2012 12:50
Script to install cURL CA certificates on OS X without macports
#!/bin/bash
mkdir /tmp/curl-ca-bundle
cd /tmp/curl-ca-bundle
wget http://curl.haxx.se/download/curl-7.22.0.tar.bz2
tar xzf curl-7.22.0.tar.bz2
cd curl-7.22.0/lib/
./mk-ca-bundle.pl
if [ ! -d /usr/share/curl/ ]; then
sudo mkdir -p /usr/share/curl/
else