Skip to content

Instantly share code, notes, and snippets.

@yareda
yareda / humanize-duration.go
Created October 20, 2021 14:26 — forked from harshavardhana/humanize-duration.go
humanizeDuration humanizes time.Duration output to a meaningful value - golang's default ``time.Duration`` output is badly formatted and unreadable.
package main
import (
"fmt"
"math"
"time"
)
// humanizeDuration humanizes time.Duration output to a meaningful value,
// golang's default ``time.Duration`` output is badly formatted and unreadable.

Keybase proof

I hereby claim:

  • I am yareda on github.
  • I am yared (https://keybase.io/yared) on keybase.
  • I have a public key ASA--XIsaDWqj1LmcOSLTMOrERxLiZK2upXjU5f2zPh6kwo

To claim this, I am signing this object:

@yareda
yareda / output.txt
Created March 6, 2018 14:32 — forked from freeeve/output.txt
database/sql/rows to json...
eve-macbook:~ go run rowstojson.go
[
{
"id": 0,
"name": "Peck Duran",
"street": "Chapel Street",
"city": "Orbin",
"zip": "94999",
"state": "Maine",
"email": "ppppp@bbb.com",
@yareda
yareda / ReceiptController.java
Created January 4, 2017 08:30
Swagger annotation in Spring Boot controller
package org.cats.stock.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.cats.stock.domain.Receipt;
import org.cats.stock.service.ReceiptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class GithubWatchRepoTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.base_url = "https://github.com"
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class GithubSearchTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.base_url = "https://github.com"
@yareda
yareda / github_search.py
Created September 16, 2015 11:41
Search for selenium on github.com
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("https://github.com")
search_field = driver.find_element_by_name('q')
search_field.send_keys("selenium")
search_field.send_keys(Keys.RETURN)
assert "We’ve found" in driver.page_source
driver.close()
task prefixNewMigrations {
fileTree(dir: 'dev/src/db/listhub').exclude({ isFilePrefixed(it.file) }).each { file ->
doLast {
def timestamp = new Date().format('yyyyMMddHHmmssSSS', TimeZone.getTimeZone('GMT'))
println "Renaming $file.name to ${timestamp}__$file.name"
file.renameTo("$file.parentFile.absolutePath$file.separator${timestamp}__$file.name")
@yareda
yareda / UserIdentity.cs
Created April 28, 2013 09:54
CustomIdentity and CustomPrincipal Classes
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
namespace Application1.Security
{
public class UserIdentity : IIdentity
<script>
chrome.browserAction.onClicked.addListener(function(tab) {
var script = "function iprl5(){var d=document,z=d.createElement('scr'+'ipt'),b=d.body,l=d.location;try{if(!b)throw(0);d.title='(Saving...) '+d.title;z.setAttribute('src',l.protocol+'//www.instapaper.com/j/lc7ra7TCeGz5?u='+encodeURIComponent(l.href)+'&t='+(new Date().getTime()));b.appendChild(z);}catch(e){alert('Please wait until the page has loaded.');}}iprl5();void(0)"
chrome.tabs.executeScript(tab.id, {code: script});
});
</script>