Skip to content

Instantly share code, notes, and snippets.

View scdekov's full-sized avatar
🎯
Focusing

Svetoslav Dekov scdekov

🎯
Focusing
View GitHub Profile
export const moveBoxCorner = (box: BoundingBox, newCorner: Point) => {
if (box.resizingCorner === 'topLeft') {
return {
...box,
startX: newCorner.x,
startY: newCorner.y,
width: box.width + box.startX - newCorner.x,
height: box.height + box.startY - newCorner.y
}
} else if (box.resizingCorner === 'topRight') {
const NotesList = () => {
const [notes, setNotes] = useState([{tile: '...', text: '...'}]);
const saveNote = (noteId, newData) => {
// api call here
setNotes(oldNotes => oldNotes.map(note => note.id === noteId ? {...newData} : note));
}
return (
<div>{notes.map(note => <Note note={note} saveNote={(newData) => saveNote(note.id, newData)}/>)}</div>
{() => Object.entries(this.state.lastAdded).length === 0 && false ? '' : (
<div>
<h4>Last Added</h4>
<p>Excercise: {this.state.lastAdded.excercise}</p>
<p>Reps: {this.state.lastAdded.reps}</p>
<p>Weight: {this.state.lastAdded.weight} kg</p>
<p>Time Length: {this.state.lastAdded.timeLength}</p>
<p>Notes: {this.state.lastAdded.notes}</p>
</div>
)}
def restart(self):
restart_all_messages = not self.filters
while True:
if not restart_all_messages and not self.filters:
return
messages = self._retrieve_messages()
if not messages:
return
class ProductDataExtractor:
def __init__(self, response):
self.response = response
def extract_data(self):
pass
def get_title(self):
return self.response.xpath('//*[@id="productTitle"]/text()').strip()
import re
import scrapy
product = {
'url': 'https://www.amazon.co.uk/Asmodee-ASMDOBB01EN-Dobble-Card-Game/dp/B0031QBHMA/'
}
@scdekov
scdekov / cloudSettings
Created February 2, 2019 20:15
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-02-02T20:14:15.023Z","extensionVersion":"v3.2.4"}
@scdekov
scdekov / .rb
Created January 28, 2019 15:22
#!/usr/bin/env ruby
class MegaGreeter
attr_accessor :names
def initialize(names = 'World')
@names = names
end
def say_hi
@scdekov
scdekov / .rb
Created January 28, 2019 15:07
def curry(func, *args)
def wrapped(*new_args)
args = args.concat new_args
if args.length == func.arity
func.call(*args)
else
curry func, args
end
end
end
myPromise
.then(() => {
// ...
})
.then(() => {
// ...
})
.catch(() => {
// ..
});