This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from idp_data.idp_data.models import Event, EventAction | |
id = '103' | |
original_event = Event.objects.get(pk=id) | |
new_event = Event.objects.get(pk=id) | |
new_event.pk = None | |
new_event.id = None | |
new_event._state.adding = True | |
new_event.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d = {'a': True, 'b': False} | |
# Without assignment expressions | |
if d['a']: | |
a = d['a'] | |
print(a) | |
# => True | |
if d['b']: | |
b = d['b'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Firefox | |
Date.parse('2021-03-03 06:00') | |
//=> 1614744000000 | |
// Chrome | |
Date.parse('2021-03-03 06:00') | |
//=> 1614751200000 | |
// Safari | |
Date.parse('2021-03-03 06:00') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#main.rb | |
class Super | |
def initialize(val) | |
@val = val | |
end | |
def val? | |
@val | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Credit: https://twitter.github.io/birdwatch/about/ranking-notes/ | |
import pandas as pd | |
notes = pd.read_csv("notes-00000.tsv", sep="\t") | |
ratings = pd.read_csv("ratings-00000.tsv", sep="\t") | |
ratingsWithNotes = notes.set_index("noteId").join( | |
ratings.set_index("noteId"), lsuffix="\_note", rsuffix="\_rating", how="inner" | |
) | |
ratingsWithNotes["numRatings"] = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.github/workflow/test.yaml | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Test | |
run: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Dockerfile | |
#model_artifacts image | |
FROM python:3.7.7-slim-buster AS model_artifacts | |
WORKDIR /artifacts | |
ADD https://bucketname.s3-eu-west-1.amazonaws.com/really_big_model_1.h5 . | |
ADD https://bucketname.s3-eu-west-1.amazonaws.com/really_big_model_2.h5 . | |
#app image | |
FROM python:3.7.7-slim-buster AS app | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//example1.js | |
const func1 = (foo, bar)=> { | |
const num1 = Math.pow(foo, 2) | |
const num2 = Math.pow(bar, 2) | |
} | |
//example2.js | |
const func1 = (foo, bar)=> { | |
const num1 = foo **2 | |
const num2 = bar **2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sessionStorage.test | |
//=> undefined | |
sessionStorage.test = null | |
//=> null | |
sessionStorage.test | |
//=> "null" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cy.visit('/404') | |
//=> Test fails | |
cy.visit('/404', {failOnStatusCode: false}) | |
//=> Test passes but does not test the HTTP code was 404 | |
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404) | |
cy.visit('/404', {failOnStatusCode: false}) | |
//=> Test passes, tests that the HTTP code was 404, and tests page was visited |