Skip to content

Instantly share code, notes, and snippets.

fn main() {
let mut s1 = String::from("Hello");
let len = calculate_length(&s1);
println!("The length of '{}' is {}.", s1, len);
change(&mut s1);
println!("The length of '{}' is {}.", s1, len);
references_example_1();
fn main() {
let mut s1 = String::from("Hello");
let len = calculate_length(&s1);
println!("The length of '{}' is {}.", s1, len);
change(&mut s1);
println!("The length of '{}' is {}.", s1, len);
references_example_1();
fn main() {
vector_1();
vector_2();
vector_3();
vector_4();
vector_5();
vector_6();
}
fn vector_1() {
@spareslant
spareslant / Vagrantfile
Created December 26, 2020 23:31
k8s multinode cluster Vagrantfile file
all_hosts = [
{
vagrant_hostname: "master",
full_hostname: "amachine.virtual.machine",
vmbox: "fedora/31-cloud-base",
vmbox_version: "31.20191023.0",
ip: "10.0.0.10",
memory: 2048,
cpus: 1
},
@spareslant
spareslant / create_self_signed_ca_and_cert.sh
Last active June 28, 2020 19:56
non-interactive self signed CA and Server cert generation
#! /bin/bash
CERTS_DIR=/tmp/myCerts
rm -rf $CERTS_DIR
mkdir -p $CERTS_DIR
CN_NAME="192.168.0.20"
CA_DOMAIN="${CN_NAME}"
ALT_IP="${CN_NAME}"
@spareslant
spareslant / create_json_paths.py
Created January 9, 2017 13:50
Creates Full paths from root node to leaf node in a JSON file
#! /usr/bin/env python
# This programm will create paths from root nodes to leafnodes along with values from any json file or structure.
import json
import pprint
json_data = open('sample_json_file.json', 'r').read()
json_dict = json.loads(json_data)
class A
def methoda_public
puts "Hello from methoda_public self=#{self}"
end
def methoda_private
puts "Hello from methoda_private self=#{self}"
end
def methoda_protected
class OuterClass {
private String outerClassPrivateInstanceVar = "outerClassPrivateInstanceVar";
public static String outerClassPublicStaticVar = "outerClassPublicStaticVar";
public String outerClassPublicInstanceVar = "outerClassPublicInstanceVar";
void outerClassInstanceMethod() {
System.out.println("Inside outerClassInstanceMethod.");
}
static void outerClassStaticMethod() {
heat_template_version: 2015-10-15
description: Apache Web server installation template.
parameters:
flavor_name:
type: string
description: Instance type for server
default: m1.small
package main
import (
"crypto/rand"
"flag"
"fmt"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
"github.com/rackspace/gophercloud/openstack/compute/v2/flavors"
"github.com/rackspace/gophercloud/openstack/compute/v2/images"