Skip to content

Instantly share code, notes, and snippets.

View rc1021's full-sized avatar
🏠
Working from home

許益銘 rc1021

🏠
Working from home
View GitHub Profile
@mzaglia
mzaglia / hyper-v-static-ip.md
Last active March 7, 2024 09:02
Static IP Hyper-V Ubuntu VM

First in a powershell create a new network switch

New-VMSwitch -SwitchName "SwitchName" -SwitchType Internal
Get-NetAdapter       // (note down ifIndex of the newly created switch as INDEX)
New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex <INDEX>
New-NetNat -Name MyNATnetwork -InternalIPInterfaceAddressPrefix 192.168.0.0/24

In your ubuntu server open your network netplan

@wesleybliss
wesleybliss / docker-compose-node-mongo.yml
Created September 9, 2016 21:37
Docker Compose with example App & Mongo
version: '2'
services:
myapp:
build: .
container_name: "myapp"
image: debian/latest
environment:
- NODE_ENV=development
- FOO=bar
volumes:
public static IEnumerable<IEnumerable<T>> Split<T>(this T[] array, int size)
{
for (var i = 0; i < (float)array.Length / size; i++)
{
yield return array.Skip(i * size).Take(size);
}
}
@andyshinn
andyshinn / Dockerfile
Created December 24, 2015 19:07
BusyBox cron container example
FROM gliderlabs/alpine:3.3
COPY myawesomescript /bin/myawesomescript
COPY root /var/spool/cron/crontabs/root
RUN chmod +x /bin/myawesomescript
CMD crond -l 2 -f
<script type="text/javascript">
$(function () {
$("#user_success").on('submit', function(){
var message = "";
var emptyValue = false;
var name = $('[name="name"]', $(this)).val();
var area = $('select[name="area"] option:selected', $(this)).val();
var time = $('select[name="time"] option:selected', $(this)).val();
var email = $('[name="email"]', $(this)).val();
var phone = $('[name="phone"]', $(this)).val();
@jonathantneal
jonathantneal / README.md
Last active March 19, 2024 23:31
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@soheilhy
soheilhy / nginxproxy.md
Last active May 8, 2024 09:56
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@rajivseelam
rajivseelam / A.README
Last active June 7, 2017 06:15
Create Google Alert and grab the feed.
Google alerts is a way to manage your content by subscribing to keywords. Here is an example on how to make that google alert with php.
Get the feed url and parse the feed. There won't be any feed available as soon the alert is created.
-------------------------------------
Copy composer.json and do composer update.
Add this to providers
@pkuczynski
pkuczynski / parse_yaml.sh
Last active April 9, 2024 18:36
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@vyspiansky
vyspiansky / build-tree.php
Last active October 2, 2023 14:36
PHP: convert object / array to tree structure
<?php
/**
* The below functions take the single level array of items as an argument
* and turn it into a multidimensional array structure (tree),
* where each item has an array of sub-items.
*
* Each item should have at least an `id` and `parent_id`,
* where the `parent_id` is `0` if it's top level.
*
* Source: http://goo.gl/p2GybZ