This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
unknown_os () | |
{ | |
echo "Unfortunately, your operating system distribution and version are not supported by this script." | |
echo | |
echo "You can override the OS detection by setting os= and dist= prior to running this script." | |
echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version" | |
echo | |
echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
from __future__ import print_function | |
from time import sleep | |
string = "The words in this sentence should appear letter by letter." | |
print("Please wait if you don't see another sentence appearing below.", end="\n\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
// tsConvert convert timestamp in "YYYY-MM-DDTHH:MM" format from one timezone to another | |
func tsConvert(ts string, fromTZ string, toTZ string) (string, error) { | |
la, _ := time.LoadLocation(fromTZ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
user_agent = request.headers.get('User-Agent') | |
return '<p>Your browser is {}!</p>'.format(user_agent) | |
@app.route('/user/<name>') | |
def user(name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package findgo | |
import ( | |
"io/fs" | |
"path/filepath" | |
) | |
func Files(folder fs.FS) int { | |
var count int | |
fs.WalkDir(folder, ".", func(p string, d fs.DirEntry, err error) error { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type Animal interface { | |
Speak() string | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main() { | |
// if ipt, err := iptables.NewWithProtocol(iptables.ProtocolIPv4); err == nil { | |
// rule := []string{"-m", "ttl", "--ttl-eq", "1", "-p", "tcp", "-d", raddr.IP.String(), "--dport", fmt.Sprint(raddr.Port), "-j", "DROP"} | |
// if exists, err := ipt.Exists("filter", "OUTPUT", rule...); err == nil { | |
// if !exists { | |
// if err = ipt.Append("filter", "OUTPUT", rule...); err == nil { | |
// conn.iprule = rule | |
// conn.iptables = ipt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package practice; | |
import java.util.Random; | |
import java.util.Scanner; | |
public class RockPaperScissors { | |
public static void main(String... args) { | |
Scanner sc = new Scanner(System.in); | |
Random r = new Random(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rand::Rng; | |
use std::cmp::Ordering; | |
use std::io; | |
fn main() { | |
println!("Guess the number!"); | |
let secret_number = rand::thread_rng().gen_range(1..101); | |
loop { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: install and start jenkins | |
hosts: web | |
become: yes | |
tasks: | |
- name: add redhat-stable jenkins repo | |
ansible.builtin.get_url: | |
url: https://pkg.jenkins.io/redhat-stable/jenkins.repo | |
dest: /etc/yum.repos.d/jenkins.repo |
NewerOlder