Skip to content

Instantly share code, notes, and snippets.

View 2hamed's full-sized avatar
🏠
Working from home

Hamed Momeni 2hamed

🏠
Working from home
View GitHub Profile
package main
import (
"context"
"fmt"
"net/http"
"time"
"github.com/felixge/httpsnoop"
"github.com/go-chi/chi"
alias gck='git checkout'
alias gps='git push'
alias gpl='git pull'
alias gs='git status'
alias gcm='git commit'
alias gf='git fetch'
alias k='kubectl'
alias kctx='kubectx'
alias kns='kubens'
@2hamed
2hamed / client.go
Created February 24, 2021 09:23
http server/client to showcase timeout
package main
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
type rt struct {
@2hamed
2hamed / Done.json
Last active November 26, 2019 11:46
Done JSON schema
// this is the main done item
{
"id": 123,
"title": "this is the title of done",
"content": "full description of the done, may exceed many lines",
"done_count": 1000,
"redone_count": 145,
"created_at": "dd:mm:YYYYTHH:mm:ss+0000",
"updated_at": "dd:mm:YYYYTHH:mm:ss+0000",
"user":{
Flowable.interval(10, TimeUnit.SECONDS)
.flatMap {api.getJson()}
.subscribe({
// do something with response
}, {
// log the error
})
RUN sed -i 's/pm.max_children = 5/pm.max_children = 10/g' /etc/php/7.2/fpm/pool.d/www.conf && \
sed -i 's/pm.start_servers = 2/pm.start_servers = 4/g' /etc/php/7.2/fpm/pool.d/www.conf && \
sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 3/g' /etc/php/7.2/fpm/pool.d/www.conf && \
sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 5/g' /etc/php/7.2/fpm/pool.d/www.conf && \
sed -i 's/;pm.max_requests = 500/pm.max_requests = 500/g' /etc/php/7.2/fpm/pool.d/www.conf && \
sed -i 's|listen = /run/php/php7.2-fpm.sock|listen = "9000"|g' /etc/php/7.2/fpm/pool.d/www.conf && \
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 500M/g' /etc/php/7.2/fpm/php.ini && \
sed -i 's/post_max_size = 8M/post_max_size = 500M/g' /etc/php/7.2/fpm/php.ini
var mode: Mode = Mode.Idle
set(value) {
field = value
invalidate()
}
var progress = 0
set(value) {
field = value
invalidate()
}
override fun onDraw(canvas: Canvas) {
when (mode) {
Mode.Loading -> {
canvas.drawArc(arcRect, 0f, 360f * (progress.toFloat() / 100f), true, outerPaint)
canvas.drawCircle(cx, cy, radius - radiusDiff, innerPaint)
...
private val arcRect = RectF()
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
if (measuredHeight > 0 && measuredWidth > 0) {
...
arcRect.set(0f, 0f, measuredWidth.toFloat(), measuredHeight.toFloat())
}
}
var mode: Mode = Mode.Idle
override fun onDraw(canvas: Canvas) {
when (mode) {
Mode.Ready -> {
canvas.drawCircle(cx, cy, radius, outerPaint)
canvas.drawCircle(cx, cy, radius - radiusDiff, innerPaint)
canvas.drawCircle(cx, cy, recordRadius, recordPaint)
}
Mode.Recording -> {