Skip to content

Instantly share code, notes, and snippets.

VBox -> File -> Host Network Manager (Ctrl-W)
Configure Adapter Manually
IPV4 Address: 192.168.56.1
IPv4 Mask: 255.255.255.0
IPv6 Address: fe80::grayed out
IPv6 Prefix Ln: 64
VBox -> Settings -> Network
Attached to: Host-only Adapter
Name: VirtualBox Host-Only Ethernet Adapter #2
@weezer
weezer / node-custom-setup.yaml
Created December 10, 2019 20:44 — forked from jjo/node-custom-setup.yaml
Run commands at Kubernetes *nodes* via `privileged` DaemonSet + `nsenter` hack, very useful for setups requiring base packages pre-installed at nodes. Please take a moment to understand what it does, and *don't* use it for *production*. Grab the logs with: kubectl logs -n kube-system -l k8s-app=node-custom-setup -c init-node
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
namespace: kube-system
name: node-custom-setup
labels:
k8s-app: node-custom-setup
annotations:
command: &cmd apt-get update -qy && apt-get install -qy tgt ceph-fs-common ceph-common xfsprogs
class Solution(object):
def longest_k_sum(self, lst, k):
kv = {0: -1}
sum_val = 0
ans = 0
for i in range(len(lst)):
sum_val += lst[i]
if not kv.get(sum_val):
kv[sum_val] = i
if kv.get(sum_val - k) is not None:
@weezer
weezer / move_box.py
Created March 29, 2018 00:02
move box
import random
class Employee(object):
def __init__(self):
self.id = random.randint(10)
def get_employee_id(self):
return self.id
class Project(object):
# beginWord = "hit"
# endWord = "cog"
# wordList = ["hot","dot","dog","lot","log","cog"]
# As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog",
# return its length 5.
#
class Vertex(object):
def __init__(self, id):
# Complete the function below.
import operator
def dfs(grid_matrix, i, j):
if i > len(grid_matrix) - 1 or i < 0 or j > len(grid_matrix[0]) - 1 or j < 0:
return
if grid_matrix[i][j] == 'N':
return
grid_matrix[i][j] = 'N'
- name: Check if image iso(s) already exist
stat:
path: "/var/www/pxe/iso/{{ item.value.image_name }}"
register: existing_file
with_dict: "{{ images }}"
- name: Veirfy the md5 of exisiting iso(s)
block:
- set_fact:
md5_result: "{{ md5_result|default({}) | combine( { item.item.key : item.stat.md5} ) }}"
@weezer
weezer / coreinfo
Created February 1, 2018 22:39 — forked from stedolan/coreinfo
Prints number of cores, CPU topology and cache topology/size on Linux machines
#!/bin/bash
unshared () {
grep '^[0-9]\+$' "$1" > /dev/null
}
for cpu in $(ls -d /sys/devices/system/cpu/cpu[0-9]* | sort -t u -k 3 -n); do
echo "${cpu##*/}: [Package #$(cat $cpu/topology/physical_package_id), Core #$(cat $cpu/topology/core_id)]"
if ! unshared $cpu/topology/core_siblings_list; then
echo " same package as $(cat $cpu/topology/core_siblings_list)"
#!/usr/bin/env bash
mkdir -p ~/Project/splunk
cd ~/Project/splunk
git clone -b 7.0.1 https://github.com/splunk/docker-splunk.git
cd docker-splunk/enterprise/
docker build -t splunk/splunk:7.0.1 .
docker-compose up &
PS1='[\[\e[32m\]#\##\[\e[31m\]\u@\[\e[36m\]\h \w]\$\[\e[m\]'