Skip to content

Instantly share code, notes, and snippets.

View jcamilom's full-sized avatar

Camilo Muñoz jcamilom

  • Medellín, Colombia
View GitHub Profile
@jcamilom
jcamilom / RemoveNewLineFromInput.go
Last active May 3, 2018 19:58
[Remove new line from input] Remove the new line char from a string acquired using io.Reader.ReadString. Solution from https://flaviocopes.com/golang-remove-new-line-from-readstring/ #golang #go #input
package main
import (
"bufio"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
@jcamilom
jcamilom / AccessingString.go
Created May 3, 2018 20:05
[Accessing bytes and chars of a string] Getting the corresponding bytes and chars that compose a string. From https://golangbot.com/strings/ #go #golang #strings
package main
import (
"fmt"
)
func printBytes(s string) {
for i:= 0; i < len(s); i++ {
fmt.Printf("%x ", s[i])
}
@jcamilom
jcamilom / AccessingStringRunes.go
Last active May 3, 2018 20:13
[Accessing bytes and runes of a string] Getting the corresponding bytes and runes that compose a string. From https://golangbot.com/strings/ #go #golang #strings
package main
import (
"fmt"
)
func printBytes(s string) {
for i:= 0; i < len(s); i++ {
fmt.Printf("%x ", s[i])
}
@jcamilom
jcamilom / MutateString.go
Created May 3, 2018 20:17
[Mutate string] How to change individual chars of a string. From https://golangbot.com/strings/ #go #golang #strings
package main
import (
"fmt"
)
func mutate(s []rune) string {
s[0] = 'a'
return string(s)
}
@jcamilom
jcamilom / RemoveNonEmptyFolder.sh
Created May 3, 2018 20:36
[Remove non-empty folders in Linux] How to remove folders in Linux that contains other files and folders #linux
#!/bin/sh
# Remove folder that contains other files or directories
rm -r mydir
# Avoid getting the delete confirmation for each file
rm -rf mydir
@jcamilom
jcamilom / icongen.sh
Created June 26, 2018 02:26
[Create icons] How to create different sized icons for apps in Linux #linux #bash
#!/bin/bash
# This will create icons in their respective
# folders in "$HOME"/.local/share/icons/...
# Usage: icongen iconfile
# Check usage
if [[ $# -ne 2 ]]; then
echo "Usage: $0 icon_file new_icon_name"
@jcamilom
jcamilom / side-menu.component.css
Created June 8, 2020 00:25
[Side Menu] Angular side menu with slide up/down animation #angular #animations
/* #F16257 is p0 */
/* #ef493e is p0 -5% luminosity */
/* #ed3326 is p0 -10% luminosity */
/* #F1A157 is s0 */
:host {
display: flex;
flex-direction: column;
}
@Component({
selector: 'simple-check-option',
template: `
<label>
<input type="checkbox" [formControl]="control">
{{ label }}
</label>
`
})
export class SimpleCheckOptionComponent {
<multi-check-field>
<simple-check-option *ngFor="let option of options" [value]="option"
[label]="option.label">
</single-check-option>
</multi-check-field>
@Component({
selector: 'multi-check-field',
template: `<ng-content></ng-content>`
})
export class MultiCheckFieldComponent implements AfterContentInit {
@ContentChildren(SimpleCheckOptionComponent)
options!: QueryList<SimpleCheckOptionComponent>;
ngAfterContentInit(): void {