Skip to content

Instantly share code, notes, and snippets.

View andreabreu-me's full-sized avatar

André Abreu andreabreu-me

View GitHub Profile
@rtucker
rtucker / setdnstarget.sh
Created August 27, 2009 00:11
A one-liner to set a Linode DNS Manager target to your client's current public IP address
ssh you@yourlinode "wget -O - -q https://api.linode.com/?api_key=$LINODE_API_KEY\&api_action=domain.resource.update\&domainid=$DOMAINID\&resourceid=$RESOURCEID\&target=\`echo \$SSH_CLIENT | cut -d' ' -f1\`"
@justinobney
justinobney / angular-get-service-console.js
Last active April 15, 2021 16:29
Get a reference to some angular service in the console
// Get the injector
var injector = angular.element($0/*'[data-ng-app], [ng-app]'*/).injector();
// Get the service
var Service = injector.get('Service');
// Use it!
// Service.addNotification('Some Notification', 'info');
@ingdir
ingdir / gist:0b211b9253c376f9cfa5
Last active December 3, 2023 11:47
BEM Cheatsheet

BEM Cheatsheet

BLOCK

Block encapsulates a standalone entity that is meaningful on its own.

While blocks can be nested and interact with each other, semantically they remain equal; there is no precedence or hierarchy.

Holistic entities without DOM representation (such as controllers or models) can be blocks as well.

@nickrussler
nickrussler / gist:7527851
Created November 18, 2013 13:39
Convert Date String to/from ISO 8601 respecting UTC in Java
public static String toISO8601UTC(Date date) {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
df.setTimeZone(tz);
return df.format(date);
}
public static Date fromISO8601UTC(String dateStr) {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
@twolfson
twolfson / README.md
Last active November 26, 2019 18:27
CSS selector minifier concept

CSS selector minification is a missed opportunity of saved bytes. Currently, Google uses it but not much beyond that.

The concept is change .box to .b and <div class="box"> to <div class="b">.

There is room for issues with JavaScript so that should be treated as a nice-to-have and be conservatively avoided.

Approach

To convert HTML and CSS, it would be a 2 step process:

Minify CSS selectors

@evanscottgray
evanscottgray / docker_kill.sh
Last active November 7, 2023 03:40
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt
package jmodern;
import com.codahale.metrics.*;
import com.codahale.metrics.annotation.*;
import com.fasterxml.jackson.annotation.*;
import com.google.common.base.Optional;
import feign.Feign;
import feign.jackson.*;
import feign.jaxrs.*;
import io.dropwizard.Application;
@staltz
staltz / introrx.md
Last active June 29, 2024 15:58
The introduction to Reactive Programming you've been missing
@n1ru4l
n1ru4l / ArtistList.js
Created January 24, 2017 15:42
mobx + apollo-client + react
import React from 'react'
import { observer } from 'mobx-react'
function ArtistList({ uiState: { artistData } }) {
const { data } = artistData;
if ( !data || !data.artists || !data.artists.length ) {
return <div>No artists bruh.</div>
}
const { artists } = data
return (
@esotrope
esotrope / gist:269a47a1315a6dd505cf8fb306489476
Last active November 20, 2021 14:41
autovalue vs lombok vs immutables syntax
/*
curl -X POST -H "Content-Type: application/json" -d '{"children":[{"id":"0"},{"id":"1"}],"childrenById":{"2":{"id":"2"}}}' http://localhost:8080/api/immutables
*/
@RestController
@RequestMapping("/api/lombok")
public class LombokController {
@RequestMapping(method = RequestMethod.GET)
public Parent get() {