diff --git a/_posts/2019-06-23-pynit.md b/_posts/2019-06-23-pynit.md new file mode 100644 index 0000000..6312199 --- /dev/null +++ b/_posts/2019-06-23-pynit.md @@ -0,0 +1,73 @@ +--- +title: pynit +categories: projects +--- + +pynit is a personal archival script that relies on `pinboard.in`. it pulls in posts through the reddit api (by way of `praw`) and adds them to the linked `pinboard` account. + +i use reddit (foolish, i know) to keep up to date on a lot of bullshit in the world, although primarily: + +- fashion +- emacs / org-mode +- powershell +- homelabs +- secops + +my typical workflow for seeing a piece of content that was useful looked something like: + +``` +view content +peruse comments (usually, the most useful part of the reddit entry) +find something that i want to revist +save it for later inside of reddit +forget about it forever, maybe revisit it within 3 months if i'm very bored +in the interim, many of the comments are deleted, links don't work, parent URL points to a dead webserver +``` + +this is obviously not ideal. pynit helps me with about half of those problems. specifically, because i pay for `pinboard`'s archiving service, i can preserve the context in the comment section of the reddit entry. links may still be broken, but i'm perfectly fine with using archive.org for viewing the links later if i need to. as i mentioned, comments end up being the most useful thing to me most of the time. + +it should be noted that `pinboard` can be used to archive the parent URL context as well, but i opted not to do that in order to preserve some semblance of readability in my `pinboard` feed. + +comments are also possible to be preserved through things resavr, ceddit, removeddit, etc. these type of sites go down regularly and are not very reliable in my experience (although resavr looks promising, if limited. it only archives comments that are deleted that are > 1000 characters). + +now whenever i want to revisit a particular item i have all the comments preserved via pinboard, and URLs can be usable (most of the time) through archive.org. + +i learned a few things that i want to write up here, all related to python or working with rest apis: + +## python + +i learned about [pysnoop](https://github.com/cool-RR/PySnooper) through [@mrled](https://github.com/mrled/) and it was SO useful. there may be more ways to use it (read their github page, its got great examples), but i primarily used it by decorating a function i wanted to inspect, like: + +``` +import pysnooper + +@pysnooper.snoop() +def my_function(): + var1 = 'thing1' + var2 = 'thing2' + + return(var1 + var2) + +print(my_function()) + +``` + +this would return: + +``` +19:54:53.048881 call 4 def my_function(): +19:54:53.049021 line 5 var1 = 'thing1' +New var:....... var1 = 'thing1' +19:54:53.049094 line 6 var2 = 'thing2' +New var:....... var2 = 'thing2' +19:54:53.049155 line 8 return(var1 + var2) +19:54:53.049197 return 8 return(var1 + var2) +Return value:.. 'thing1thing2' +thing1thing2 + +``` + +this allowed me to simple add a single line to an exist function /without modifying the function itself at all/ and make sure I was actually doing what I thought I was doing. this was huge for letting me sanity check my work. + +## rest apis +a lot of people (a lot of people!!) just have you use get requests instead of posts, even when you're posting stuff. i am not a Web Man, so i don't understand the why, but if all you've ever done is /read/ about working with rest apis then the real world may be confusing when you try and post something that requires a get request. [pinboard api docs](https://pinboard.in/api) for instance require get requests when you mean posts for backwards compatibility with the `delicious` api. diff --git a/_site/index.html b/_site/index.html index d73ceba..b936dfa 100644 --- a/_site/index.html +++ b/_site/index.html @@ -4,7 +4,7 @@ - + diff --git a/_site/personal/2019/04/15/friendsgiving.html b/_site/personal/2019/04/15/friendsgiving.html index 193d245..6096e29 100644 --- a/_site/personal/2019/04/15/friendsgiving.html +++ b/_site/personal/2019/04/15/friendsgiving.html @@ -4,7 +4,7 @@ - + diff --git a/_site/personal/2019/04/15/lt_thanksgiving.html b/_site/personal/2019/04/15/lt_thanksgiving.html index 42de3f0..29dfe12 100644 --- a/_site/personal/2019/04/15/lt_thanksgiving.html +++ b/_site/personal/2019/04/15/lt_thanksgiving.html @@ -4,7 +4,7 @@ - + diff --git a/_site/personal/2019/04/15/rad_boys_only.html b/_site/personal/2019/04/15/rad_boys_only.html index bd59bdf..ca3d0a4 100644 --- a/_site/personal/2019/04/15/rad_boys_only.html +++ b/_site/personal/2019/04/15/rad_boys_only.html @@ -4,7 +4,7 @@ - + diff --git a/_site/personal/2019/04/18/vcards.html b/_site/personal/2019/04/18/vcards.html index bc9c76b..9572fd1 100644 --- a/_site/personal/2019/04/18/vcards.html +++ b/_site/personal/2019/04/18/vcards.html @@ -4,7 +4,7 @@ - + diff --git a/_site/personal/index.html b/_site/personal/index.html index ab39a10..c683f4a 100644 --- a/_site/personal/index.html +++ b/_site/personal/index.html @@ -4,7 +4,7 @@ - + diff --git a/_site/projects/2019/04/15/hosting_static_sites_on_s3.html b/_site/projects/2019/04/15/hosting_static_sites_on_s3.html index 0a4aef6..9b56859 100644 --- a/_site/projects/2019/04/15/hosting_static_sites_on_s3.html +++ b/_site/projects/2019/04/15/hosting_static_sites_on_s3.html @@ -4,7 +4,7 @@ - + diff --git a/_site/projects/2019/04/15/mojojojo_bot.html b/_site/projects/2019/04/15/mojojojo_bot.html index a19ccf3..c3ec519 100644 --- a/_site/projects/2019/04/15/mojojojo_bot.html +++ b/_site/projects/2019/04/15/mojojojo_bot.html @@ -4,7 +4,7 @@ - + diff --git a/_site/projects/2019/04/15/workingcopy.html b/_site/projects/2019/04/15/workingcopy.html index 14f20b7..7d6d1db 100644 --- a/_site/projects/2019/04/15/workingcopy.html +++ b/_site/projects/2019/04/15/workingcopy.html @@ -4,7 +4,7 @@ - + diff --git a/_site/projects/2019/06/23/pynit.html b/_site/projects/2019/06/23/pynit.html new file mode 100644 index 0000000..5a95a00 --- /dev/null +++ b/_site/projects/2019/06/23/pynit.html @@ -0,0 +1,124 @@ + + + + + + + + + + + + +pynit | josiah ledbetter + + + + + + + + + + + + + + + + +
+
+ +
+

josiah ledbetter

+
+
+ + +
+
+
+

pynit is a personal archival script that relies on pinboard.in. it pulls in posts through the reddit api (by way of praw) and adds them to the linked pinboard account.

+ +

i use reddit (foolish, i know) to keep up to date on a lot of bullshit in the world, although primarily:

+ +
    +
  • fashion
  • +
  • emacs / org-mode
  • +
  • powershell
  • +
  • homelabs
  • +
  • secops
  • +
+ +

my typical workflow for seeing a piece of content that was useful looked something like:

+ +
view content
+peruse comments (usually, the most useful part of the reddit entry)
+find something that i want to revist
+save it for later inside of reddit
+forget about it forever, maybe revisit it within 3 months if i'm very bored
+in the interim, many of the comments are deleted, links don't work, parent URL points to a dead webserver
+
+ +

this is obviously not ideal. pynit helps me with about half of those problems. specifically, because i pay for pinboard’s archiving service, i can preserve the context in the comment section of the reddit entry. links may still be broken, but i’m perfectly fine with using archive.org for viewing the links later if i need to. as i mentioned, comments end up being the most useful thing to me most of the time.

+ +

it should be noted that pinboard can be used to archive the parent URL context as well, but i opted not to do that in order to preserve some semblance of readability in my pinboard feed.

+ +

comments are also possible to be preserved through things resavr, ceddit, removeddit, etc. these type of sites go down regularly and are not very reliable in my experience (although resavr looks promising, if limited. it only archives comments that are deleted that are > 1000 characters).

+ +

now whenever i want to revisit a particular item i have all the comments preserved via pinboard, and URLs can be usable (most of the time) through archive.org.

+ +

i learned a few things that i want to write up here, all related to python or working with rest apis:

+ +

python

+ +

i learned about pysnoop through @mrled and it was SO useful. there may be more ways to use it (read their github page, its got great examples), but i primarily used it by decorating a function i wanted to inspect, like:

+ +
import pysnooper
+
+@pysnooper.snoop()
+def my_function():
+    var1 = 'thing1'
+    var2 = 'thing2'
+
+    return(var1 + var2)
+
+print(my_function())
+
+
+ +

this would return:

+ +
19:54:53.048881 call         4 def my_function():
+19:54:53.049021 line         5     var1 = 'thing1'
+New var:....... var1 = 'thing1'
+19:54:53.049094 line         6     var2 = 'thing2'
+New var:....... var2 = 'thing2'
+19:54:53.049155 line         8     return(var1 + var2)
+19:54:53.049197 return       8     return(var1 + var2)
+Return value:.. 'thing1thing2'
+thing1thing2
+
+
+ +

this allowed me to simple add a single line to an exist function /without modifying the function itself at all/ and make sure I was actually doing what I thought I was doing. this was huge for letting me sanity check my work.

+ +

rest apis

+

a lot of people (a lot of people!!) just have you use get requests instead of posts, even when you’re posting stuff. i am not a Web Man, so i don’t understand the why, but if all you’ve ever done is /read/ about working with rest apis then the real world may be confusing when you try and post something that requires a get request. pinboard api docs for instance require get requests when you mean posts for backwards compatibility with the delicious api.

+ +
+ + + +
+
+ + + + diff --git a/_site/projects/index.html b/_site/projects/index.html index 1a995df..e4d07d1 100644 --- a/_site/projects/index.html +++ b/_site/projects/index.html @@ -4,7 +4,7 @@ - +