Skip to content

Instantly share code, notes, and snippets.

package main
import(
"net/http"
)
func GetCountry(r *http.Request) string {
return r.Header.Get("CF-IPCountry")
}
@oofnivek
oofnivek / date_format.go
Created June 24, 2021 04:20
Formatting date string in Golang
package main
import (
"fmt"
"time"
)
func main() {
currentTime := time.Now()
fmt.Println("Current Time in String: ", currentTime.String())
package main
import (
"fmt"
)
type Student struct {
FirstName string
LastName string
}
const puppeteer = require('puppeteer');
const fs = require('fs');
async function run () {
const browser = await puppeteer.launch({
defaultViewport: {width: 1920, height: 1080}
});
const page = await browser.newPage();
await page.goto('https://www.google.com/search?q=bitcoin');
await sleep(3000);
package main
import (
"fmt"
"log"
"sync"
"time"
"reflect"
"net/http"
"encoding/json"
import sys
from PIL import Image
def compare_pixels(png1, png2):
pixels1 = list(png1.getdata())
pixels2 = list(png2.getdata())
if len(pixels1) != len(pixels2):
return -1 # different pixel count
match = 0
import sys
#import time
import numpy
from PIL import Image
def find_image(png_big, png_small):
arr_big = numpy.array(png_big)
arr_small = numpy.array(png_small)
if len(arr_big) < len(arr_small):
return [-2,-2] # unable to search a bigger picture in a smaller picture
import sys
import numpy as np
from PIL import Image
def verify(haystack_start_y, haystack_start_x, arr_haystack, arr_needle):
y = haystack_start_y
x = haystack_start_x
searched = 0
identical = 0
for b in range(0, len(arr_needle)):
const puppeteer = require('puppeteer');
const fs = require('fs');
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
const get_html = async() => {
require 'mysql2'
def my_db
return Mysql2::Client.new(
:host => '127.0.0.1',
:username => 'root',
:password => 'password',
:encoding => 'utf8mb4',
:database => 'medium_story',
:ssl_mode => 'disabled',