Skip to content

Instantly share code, notes, and snippets.

View srph's full-sized avatar
🛠️
Building @Stride-Labs Frontend

Kier Borromeo srph

🛠️
Building @Stride-Labs Frontend
View GitHub Profile
@srph
srph / main.go
Last active August 10, 2018 22:07
Go: Get today time.Time instance with given hour and minutes
package main
import (
"time"
)
func nowWithGivenTime(hour int, minutes int) (time.Time, error) {
today := time.Now()
l, err := time.LoadLocation("Local")
if err != nil {
@srph
srph / main.go
Created August 10, 2018 22:04
Go: Parse 3:00 AM into military time
package main
import (
"strconv"
"strings"
)
func parseTime(t string) (int, int) {
split := strings.Split(t, " ")
time := split[0]
@srph
srph / main.go
Created August 10, 2018 22:03
Go: Extract image from css style url
package main
import (
"strings"
"regexp"
)
func getThumbnailFromStyle(style string) string {
r := regexp.MustCompile("url\\((.+)\\)")
return strings.TrimRight(strings.TrimLeft(r.FindString(style), "url("), ")")
<DataTable endpoint="api.myapp.com/users">
<DataTable.Column>
{(data) =>
<span>{data.firstName} {data.lastName}</span>
)}
</DataTable.Column>
<DataTable.Column>
{(data) =>
<a href={`/user/${data.id}`}>View</a>
<SomeComponent.Footer>
{(slotProps) =>
<div>{slotProps.loading ? 'Loading...' : null}</div>
}
</SomeComponent.Footer>
@srph
srph / gist:65b56ce893705cc98e6334d9ef0099b5
Created July 1, 2018 06:42
Google Spreadsheets: Count columns of specific color
// Needs Google Spreadsheets PowerTools
=COUNTA(valuesByColor("#f4cccc", "", B4:E4))
@srph
srph / index.js
Last active June 18, 2018 03:36
JS: Organizing styled-components
const styling = {
Container: style.div`
padding: 16px;
${props => props.isBig && css`
padding: 32px;
`}
`,
Heading: styled.div`
display: flex;
`,
@srph
srph / index.js
Last active May 29, 2018 11:26
JS: X in Square coding challenge
// ++++++++++++++++
// ++ ++
// + + + +
// + + + +
// + + + +
// + + + +
// + + + +
// + ++ +
// + + + +
// + + + +
const layout = (
<BaseLayout>
<BaseLayout.Header>
<h1>Here might be a page title</h1>
</BaseLayout.Header>
<BaseLayout.Body>
<p>A paragraph for the main content.</p>
<p>And another one.</p>
</BaseLayout.Body>
function Header() {
return null
}
function Body() {
return null
}
function Footer() {
return null