Skip to content

Instantly share code, notes, and snippets.

View evaldosantos's full-sized avatar
🏠
Working from home

Evaldo Santos evaldosantos

🏠
Working from home
View GitHub Profile
sudo dnf clean all
# update the system
sudo dnf update -y
# add rpm fusion repos
sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
# add microsoft keys
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
<div ng-controller="MyCtrl">
<div id="memory">
<div class="block"
ng-repeat="block in memory.blocks"
ng-class="{used: !block.free}"
ng-style="getWidth(block)"
>{{block.id}}</div>
</div>
</div>
class MMemory {
constructor(size, memoryAllocationStrategy) {
this._size = size;
this._blocks = [];
}
totalAllocatedBlocks() {
return this._blocks.reduce( (total, block) => total + block.getSize(), 0 );
}
contacts = re.search(r''' #<-- Wrap in multiline quote. Remove leading caret (^)
(?P<email>[-\w\d.+]+@[-\w\d.]+)
,\s
(?P<phone>\d{3}-\d{3}-\d{4})''' #<-- Add closing paren. Remove extra backslashes. Remove trailing $
, string, re.X | re.M) #<-- Add verbose (for multiline quote), and multiline (for muliple lines in string) flags
re.compile(pattern, flags) - method to pre-compile and save a regular expression pattern, and any associated flags, for later use.
.groupdict() - method to generate a dictionary from a Match object's groups. The keys will be the group names. The values will be the results of the patterns in the group.
re.finditer() - method to generate an iterable from the non-overlapping matches of a regular expression. Very handy for for loops.
.group() - method to access the content of a group. 0 or none is the entire match. 1 through how ever many groups you have will get that group. Or use a group's name to get it if you're using named groups.
# working with date
>>> from datetime import datetime
>>> d = datetime.now()
>>> d = d.replace(hour=9,minute=0, second=0)
>>> e = datetime.now()
>>> time = e-s
>>> time.days
0
>>> time.seconds
# variables
name = "Evaldo"
age = 27
# output
print(name)
print(age)
# strings
'Evaldo'
@evaldosantos
evaldosantos / Read Write problem
Created October 14, 2017 14:07
Two threads trying to read a property of an object
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
import java.util.logging.Level;
import java.util.logging.Logger;
// 1 - (host step) - create a new container
$APPNAME="db"
docker run -d --name $APPNAME -v $APPNAME:/var/lib/postgresql/data -e POSTGRES_PASSWORD=1234 -p 5432:5432 postgres:9.4-alpine
// after that, the container will be running in detached mode
// 2- (host step) So, you connect to it
docker exec -it $APPNAME /bin/bash
// 3 - (host step) copy file to container, here $APPNAME is the name of running container
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
https://dist-wwgktknioc.now.sh/