mirror of
https://github.com/aljazceru/cryptoanarchywiki.github.io.git
synced 2025-12-17 05:04:21 +01:00
Strip away theme demo content
This commit is contained in:
17
_config.yml
17
_config.yml
@@ -10,11 +10,6 @@ avatar_url: /static/img/avatar.jpg
|
|||||||
enableTags: true
|
enableTags: true
|
||||||
tagarray: []
|
tagarray: []
|
||||||
|
|
||||||
collections:
|
|
||||||
project:
|
|
||||||
output: true
|
|
||||||
permalink: /project/:path/
|
|
||||||
|
|
||||||
social:
|
social:
|
||||||
- icon: fa-twitter
|
- icon: fa-twitter
|
||||||
link: "https://twitter.com/_cryptoanarchy"
|
link: "https://twitter.com/_cryptoanarchy"
|
||||||
@@ -28,13 +23,17 @@ share:
|
|||||||
fb_appid:
|
fb_appid:
|
||||||
|
|
||||||
urls:
|
urls:
|
||||||
- text: About Us
|
|
||||||
url: /about/
|
|
||||||
- text: My Projects
|
|
||||||
url: /projects/
|
|
||||||
- text: XML Feed
|
- text: XML Feed
|
||||||
url: /feed.xml
|
url: /feed.xml
|
||||||
|
|
||||||
|
similar_resources:
|
||||||
|
- text: Lopp's Bitcoin Resources
|
||||||
|
url: "https://lopp.net/bitcoin.html"
|
||||||
|
- text: Satoshi Nakamoto Institute
|
||||||
|
url: "https://nakamotoinstitute.org/"
|
||||||
|
- text: "Activism.net: Cypherpunks"
|
||||||
|
url: "https://www.activism.net/cypherpunk/"
|
||||||
|
|
||||||
url: "https://cryptoanarchywiki.github.io"
|
url: "https://cryptoanarchywiki.github.io"
|
||||||
baseurl: ""
|
baseurl: ""
|
||||||
paginate: 20
|
paginate: 20
|
||||||
|
|||||||
0
_data/.gitkeep
Normal file
0
_data/.gitkeep
Normal file
@@ -1,42 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"slug": "cool-project",
|
|
||||||
"name": "Cool project 1",
|
|
||||||
"image": "placeholder.jpg",
|
|
||||||
"url": "https://www.google.com",
|
|
||||||
"date": "Jan 2014",
|
|
||||||
"tags": ["Angular JS","API"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Cool project 2",
|
|
||||||
"image": "placeholder.jpg",
|
|
||||||
"url": "#",
|
|
||||||
"date": "May 2014",
|
|
||||||
"tags": ["Python","Django"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Cool project 3",
|
|
||||||
"image": "placeholder.jpg",
|
|
||||||
"url": "#",
|
|
||||||
"date": "June 2014",
|
|
||||||
"tags": ["HTML","JQuery","Django"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Cool project 4",
|
|
||||||
"image": "placeholder.jpg",
|
|
||||||
"date": "Oct 2016",
|
|
||||||
"tags": ["Python","nodejs"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Cool project 5",
|
|
||||||
"image": "placeholder.jpg",
|
|
||||||
"date": "Oct 2016",
|
|
||||||
"tags": ["Python","nodejs"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Cool project 6",
|
|
||||||
"image": "placeholder.jpg",
|
|
||||||
"date": "Oct 2016",
|
|
||||||
"tags": ["Python","nodejs"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
{% if site.enableTags == true %}
|
|
||||||
<div id="tag-filter" class="tag-group">
|
|
||||||
<span class="tag-filter tag-cloud all active">All</span>
|
|
||||||
|
|
||||||
{% assign tagarray = site.tagarray %}
|
|
||||||
{% for project in site.data.projects %}
|
|
||||||
{% for tag in project.tags %}
|
|
||||||
{% assign tagarray = tagarray | push: tag %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% assign tags = tagarray[1] %}
|
|
||||||
{% for item in tagarray %}
|
|
||||||
{% assign tagDown = item | downcase %}
|
|
||||||
{% assign tagComp = tags | downcase %}
|
|
||||||
{% unless tagComp contains tagDown %}
|
|
||||||
{% capture tags %}{{ tags }}|{{ item }}{% endcapture %}
|
|
||||||
{% endunless %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% assign taglist = tags | split: '|' | sort %}
|
|
||||||
{% for tag in taglist %}
|
|
||||||
<span class="tag-filter tag-cloud" data-tag="{{ tag | downcase }}">{{ tag }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
@@ -159,6 +159,13 @@ layout: compress
|
|||||||
<li><a class="about" href="{{ i.url }}">{{ i.text }}</a></li>
|
<li><a class="about" href="{{ i.url }}">{{ i.text }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<hr>
|
||||||
|
<ul class="sidebar-nav">
|
||||||
|
<strong>Similar Resources</strong>
|
||||||
|
{% for i in site.similar_resources %}
|
||||||
|
<li><a class="about" href="{{ i.url }}">{{ i.text }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!-- end /.fixed-condition -->
|
<!-- end /.fixed-condition -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
---
|
|
||||||
layout: default
|
|
||||||
---
|
|
||||||
<header class="post-header">
|
|
||||||
<h1 class="post-title">Articles by category: {{ page.categories }}</h1>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="post-content">
|
|
||||||
<hr />
|
|
||||||
{% for category in site.categories %}
|
|
||||||
{% capture category_slug %}{{ category | first }}{% endcapture %}
|
|
||||||
{% for c_slug in category_slug %}
|
|
||||||
{% if c_slug == page.categories %}
|
|
||||||
<button class="btn btn-sm btn-default active">{{ c_slug }}</button>
|
|
||||||
{% else %}
|
|
||||||
<a href="/category/{{ c_slug }}" class="btn btn-sm btn-default">{{ c_slug }}</a>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
{% if site.categories[page.categories] %}
|
|
||||||
{% for post in site.categories[page.categories] %}
|
|
||||||
{% capture post_year %}{{ post.date | date: '%Y' }}{% endcapture %}
|
|
||||||
{% if forloop.first %}
|
|
||||||
<h4>{{ post_year }}</h4>
|
|
||||||
<div class="list-group">
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if forloop.first == false %}
|
|
||||||
{% assign previous_index = forloop.index0 | minus: 1 %}
|
|
||||||
{% capture previous_post_year %}{{ site.categories[page.categories][previous_index].date | date: '%Y' }}{% endcapture %}
|
|
||||||
{% if post_year != previous_post_year %}
|
|
||||||
</div>
|
|
||||||
<h4>{{ post_year }}</h4>
|
|
||||||
<div class="list-group">
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
<ul class="posts">
|
|
||||||
<li><a href="{{ post.url }}">{{ post.title }}</a> » <i><span>{{ post.date | date_to_string }}</span></i></li>
|
|
||||||
</ul>
|
|
||||||
{% if forloop.last %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
<p>There are no posts in this categories.</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
---
|
|
||||||
layout: default
|
|
||||||
---
|
|
||||||
<article class="post">
|
|
||||||
<header class="post-header">
|
|
||||||
<h1 class="post-title">{{ page.title }}</h1>
|
|
||||||
<hr />
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="post-content">
|
|
||||||
{{ content }}
|
|
||||||
|
|
||||||
{% assign p_array = "" | split:"|" %}
|
|
||||||
{% for project in site.project %}
|
|
||||||
{% capture p_slug %}{{ project.url | split:"/" | last }},{{ project.url }}{% endcapture %}
|
|
||||||
{% assign p_slug_arr = p_slug | split:"," %}
|
|
||||||
{% assign p_array = p_array | push: p_slug_arr %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<div class="projects">
|
|
||||||
{% include project_tags.html %}
|
|
||||||
|
|
||||||
{% for i in site.data.projects %}
|
|
||||||
<div class="project-item project-outer" data-tags='{{ i.tags | jsonify | downcase }}'>
|
|
||||||
<div class="project-inner">
|
|
||||||
<a href="/static/projects/{{ i.image }}" class="thickbox">
|
|
||||||
<div class="project-img bordered" style="background-image: url('/static/projects/{{ i.image }}');"></div>
|
|
||||||
</a>
|
|
||||||
{% assign p_url = nil %}
|
|
||||||
{% for pr in p_array %}
|
|
||||||
{% if pr contains i.slug %}
|
|
||||||
{% assign p_url = pr[1] %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% if p_url == nil %}{% assign p_url = i.url %}{% endif %}
|
|
||||||
{% if p_url %}
|
|
||||||
<a class="project-detail" href="{{ p_url }}">
|
|
||||||
{% endif %}
|
|
||||||
<h3 class="project-headlines">{{ i.name }}</h3>
|
|
||||||
{% if p_url %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="project-content">
|
|
||||||
<div class="tag-holder">
|
|
||||||
{% if i.tags %}
|
|
||||||
{% for j in i.tags %}
|
|
||||||
<span class="tags tag-filter" data-tag="{{ j | downcase }}"><a href="#{{ j }}">{{ j }}</a></span>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="project-footer">
|
|
||||||
{% if i.url %}
|
|
||||||
<a href="{{ i.url }}" class="project-link" target="_blank"><i class="fa fa-globe"></i> View</a>
|
|
||||||
{% endif %}
|
|
||||||
<span class="project-timeline">{{ i.date }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
layout: default
|
|
||||||
---
|
|
||||||
<article class="post">
|
|
||||||
<header class="post-header">
|
|
||||||
<h1 class="post-title">{{ page.title }}</h1>
|
|
||||||
{% for project in site.data.projects %}
|
|
||||||
{% if project.slug == page.slug %}
|
|
||||||
<span class="time">{{ project.date }}</span> »
|
|
||||||
{% for tag in project.tags %}
|
|
||||||
<span class="tags tag-filter">{{ tag }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="content">
|
|
||||||
{% for project in site.data.projects %}
|
|
||||||
{% if project.slug == page.slug %}
|
|
||||||
<a href="/static/projects/{{ project.image }}" class="thickbox">
|
|
||||||
<img src="/static/projects/{{ project.image }}" alt="{{ page.title }}" title="{{ page.title }}">
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
<hr />
|
|
||||||
{{ content }}
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Welcome to Simply Grey"
|
|
||||||
date: 2013-12-23 00:18:23 +0700
|
|
||||||
categories: [jekyll]
|
|
||||||
---
|
|
||||||
SimplyGrey is a simple, easy to use theme for Jekyll that compromises of mainly grey colours. A lot of people enjoy the simplistic look of grey and also find it easier to read.
|
|
||||||
|
|
||||||
## Why use Simply Grey?
|
|
||||||
There are lots of reasons why I think you should use Simply Grey but I will list the main ones that I believe are more of benefit to you, the user.
|
|
||||||
|
|
||||||
+ <em>Easy to use and setup</em> - Jekyll has a huge range of documentation to get you started writing posts and the Simply Grey theme makes your blog look beautiful.
|
|
||||||
+ <em>Easy configuration</em> - I developed this theme in order to be as customisable as possible. If you want to add more links to the navigation bar, all you have to do is edit the _config.yaml file and the `urls` part of it.
|
|
||||||
+ <em>You can change it</em> - After being released with the MIT license (like Jekyll itself) you are free to change and basically do anything you want to this theme provided you keep the copyright notice in the files and distribute the license with it.
|
|
||||||
|
|
||||||
## Jekyll
|
|
||||||
Jekyll is a static site generator developed in ruby that generates websites from markdown and many other formats. The benefit of this is that you can have a highly customisable blog where you can generate posts by writing easy markdown code whilst still retaining the small memory imprint that Jekyll has.
|
|
||||||
|
|
||||||
### Code Snippets
|
|
||||||
Code Snippets are one of the main reasons why I love Jekyll and I think you will too. All code snippets become highlighted with great colours when you write the code in markdown. Here is an example of highlighted Ruby code in a weather application that I have made.
|
|
||||||
|
|
||||||
{% highlight ruby %}
|
|
||||||
#!/usr/bin/env ruby
|
|
||||||
|
|
||||||
require 'json'
|
|
||||||
require 'net/http'
|
|
||||||
require 'libnotify'
|
|
||||||
|
|
||||||
def parsejson
|
|
||||||
file = "http://api.openweathermap.org/data/2.5/find?q=London&mode=json"
|
|
||||||
response = Net::HTTP.get_response(URI.parse(file))
|
|
||||||
weatherjson = response.body
|
|
||||||
actual = JSON.parse(weatherjson)
|
|
||||||
|
|
||||||
# check for errors
|
|
||||||
if actual.has_key? 'Error'
|
|
||||||
raise "error with the url"
|
|
||||||
end
|
|
||||||
|
|
||||||
results = []
|
|
||||||
|
|
||||||
actual["list"].each do |listitem|
|
|
||||||
weather = listitem["weather"]
|
|
||||||
weather.each do |weath|
|
|
||||||
results.push(weath["description"])
|
|
||||||
end
|
|
||||||
main = listitem["main"]
|
|
||||||
temp = main["temp"] - 273.15
|
|
||||||
results.push ("%.2f" % temp)
|
|
||||||
end
|
|
||||||
|
|
||||||
return results
|
|
||||||
end
|
|
||||||
|
|
||||||
def notify(summary)
|
|
||||||
Libnotify.show(:body => "Current temperature is: #{summary[1]} degrees celsius.\nCurrent description of conditions: #{summary[0]}", :summary => "Weather Update", :timeout => 10)
|
|
||||||
end
|
|
||||||
|
|
||||||
notify(parsejson())
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
Check out the [Jekyll docs][jekyll] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll's GitHub repo][jekyll-gh].
|
|
||||||
|
|
||||||
[jekyll-gh]: https://github.com/mojombo/jekyll
|
|
||||||
[jekyll]: http://jekyllrb.com
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Download recrusive files inside index-of in Linux using wget"
|
|
||||||
date: 2016-04-19 19:39:02 +0700
|
|
||||||
categories: [bash]
|
|
||||||
---
|
|
||||||
```
|
|
||||||
$ wget -r --no-parent --reject "index.html*" http://125.160.17.22/dokumen/IGN/Panduan_OpenOffice.org_2.0/
|
|
||||||
```
|
|
||||||
|
|
||||||
For me I have to pass the --no-parent option, otherwise it will follow the link in the directory index on my site to the parent directory. So the command would look like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
wget -r --no-parent http://mysite.com/configs/.vim/
|
|
||||||
```
|
|
||||||
|
|
||||||
Edit: To avoid downloading the index.html files, use this command:
|
|
||||||
|
|
||||||
```
|
|
||||||
wget -r --no-parent --reject "index.html*" http://mysite.com/configs/.vim/
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
The Parameters are:
|
|
||||||
|
|
||||||
* `-r` //recursive Download
|
|
||||||
* `--no-parent` // Don´t download something from the parent directory
|
|
||||||
* `-l1` //just download the directory (tzivi in your case)
|
|
||||||
* `-l2` //download the directory and all level 1 subfolders ('tzivi/something' but not 'tivizi/somthing/foo')
|
|
||||||
|
|
||||||
And so on. If you insert no `-l` option, wget will use `-l` 5 automatically.
|
|
||||||
If you insert a -l 0 you´ll download the whole internet, because wget will follow every link it finds.
|
|
||||||
|
|
||||||
|
|
||||||
**Refference:**
|
|
||||||
|
|
||||||
* [http://stackoverflow.com/a/19695143/3445802](http://stackoverflow.com/a/19695143/3445802)
|
|
||||||
* [http://stackoverflow.com/a/273776/3445802](http://stackoverflow.com/a/273776/3445802)
|
|
||||||
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Email BackEnd with SMTP Gmail"
|
|
||||||
date: 2016-04-19 02:28:15 +0700
|
|
||||||
categories: [python, django]
|
|
||||||
---
|
|
||||||
Add this configurations in your `settings.py`
|
|
||||||
|
|
||||||
This configurations is if you work with `smtp.gmail.com`, other smtp is similiar with configurations.
|
|
||||||
|
|
||||||
* Unlock Captha: [https://accounts.google.com/DisplayUnlockCaptcha](https://accounts.google.com/DisplayUnlockCaptcha)
|
|
||||||
* Change to active: [https://www.google.com/settings/security/lesssecureapps](https://www.google.com/settings/security/lesssecureapps)
|
|
||||||
|
|
||||||
```
|
|
||||||
EMAIL_HOST = 'smtp.gmail.com'
|
|
||||||
EMAIL_PORT = 587
|
|
||||||
EMAIL_HOST_USER = 'your_gmail@gmail.com'
|
|
||||||
EMAIL_HOST_PASSWORD = 'your_password'
|
|
||||||
EMAIL_USE_TLS = True
|
|
||||||
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
|
||||||
```
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Python Permutations"
|
|
||||||
date: 2016-04-19 19:31:43 +0700
|
|
||||||
categories: [python]
|
|
||||||
---
|
|
||||||
This simply how to implement the module of permutations in python.
|
|
||||||
|
|
||||||
{% highlight ruby %}
|
|
||||||
>>> from itertools import permutations
|
|
||||||
>>> perms = [''.join(p)+"@gmail.com" for p in permutations('abc', 3)]
|
|
||||||
>>> for x in range(0, len(perms)):
|
|
||||||
... print (perms[x])
|
|
||||||
...
|
|
||||||
abc@gmail.com
|
|
||||||
acb@gmail.com
|
|
||||||
bac@gmail.com
|
|
||||||
bca@gmail.com
|
|
||||||
cab@gmail.com
|
|
||||||
cba@gmail.com
|
|
||||||
>>>
|
|
||||||
{% endhighlight %}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Remove all files .pyc with recrusive method"
|
|
||||||
date: 2016-04-19 14:39:34 +0700
|
|
||||||
categories: [python, bash]
|
|
||||||
---
|
|
||||||
|
|
||||||
This method simple but important. Example in your project dir is like this:
|
|
||||||
|
|
||||||
{% highlight ruby %}
|
|
||||||
project_dir/
|
|
||||||
__init__.py
|
|
||||||
__init__.pyc
|
|
||||||
something.py
|
|
||||||
something.pyc
|
|
||||||
...
|
|
||||||
core/
|
|
||||||
__init__.py
|
|
||||||
__init__.pyc
|
|
||||||
build.py
|
|
||||||
build.pyc
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
Deleting the `.pyc` files one by one would be spending a lot of time. and you will be bored. There is sample how to handle it.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ find your_dir -name *.pyc -delete
|
|
||||||
```
|
|
||||||
|
|
||||||
OR, if you work inside current directory.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ find . -name *.pyc -delete
|
|
||||||
```
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Replace backend gmail to Postmarkapp for Django"
|
|
||||||
date: 2016-04-19 20:15:33 +0700
|
|
||||||
categories: [django]
|
|
||||||
---
|
|
||||||
|
|
||||||
#### 1. Install module of Python Postmark
|
|
||||||
|
|
||||||
Install this module manually from souce inside your environtment: [https://github.com/themartorana/python-postmark](https://github.com/themartorana/python-postmark)
|
|
||||||
|
|
||||||
> If you work on `Django==1.9.*`, requirements only `mock`.
|
|
||||||
|
|
||||||
#### 2. Register and Put the Server Keys
|
|
||||||
|
|
||||||
Register and put your server API token here: https://account.postmarkapp.com/servers/101010/credentials . `101010` is id of your server.
|
|
||||||
|
|
||||||
> Makesure verified your SPF and DKIM. this configurations to allowing the permission from your domain for signature.
|
|
||||||
|
|
||||||
#### 3. Configure in `settings.py`
|
|
||||||
|
|
||||||
{% highlight ruby %}
|
|
||||||
EMAIL_USE_TLS = True
|
|
||||||
EMAIL_HOST = 'smtp.postmarkapp.com'
|
|
||||||
EMAIL_PORT = 587
|
|
||||||
POSTMARK_API_KEY = 'yourkey-yourkey-yourkey-yourkey'
|
|
||||||
POSTMARK_SENDER = 'your_company_email@domain.com'
|
|
||||||
EMAIL_HOST_USER = POSTMARK_SENDER
|
|
||||||
DEFAULT_FROM_EMAIL = POSTMARK_SENDER
|
|
||||||
POSTMARK_TEST_MODE = False
|
|
||||||
POSTMARK_TRACK_OPENS = False
|
|
||||||
EMAIL_BACKEND = 'postmark.django_backend.EmailBackend'
|
|
||||||
{% endhighlight %}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Simple bash scripting for login before open the terminal"
|
|
||||||
date: 2016-04-19 19:19:21 +0700
|
|
||||||
categories: [bash]
|
|
||||||
---
|
|
||||||
|
|
||||||
Add this in your file of `/etc/bash.bashrc`, makesure you logged in as root.
|
|
||||||
|
|
||||||
{% highlight ruby %}
|
|
||||||
### ===============================================
|
|
||||||
### Simple bash scripting for login before open the terminal.
|
|
||||||
### Credit: <Summon Agus> - agus@python.web.id
|
|
||||||
### Location, end script of: /etc/bash.bashrc
|
|
||||||
### ===============================================
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
# Don't exit at Ctrl-C
|
|
||||||
trap "echo" SIGINT
|
|
||||||
|
|
||||||
printf "\n"
|
|
||||||
echo -n " Who are you guys? "; read -s name;
|
|
||||||
if [ "$name" == "agus" ]; then
|
|
||||||
reset
|
|
||||||
printf "\n Welcome my KING! you are the best!!\n"
|
|
||||||
printf " "; date;
|
|
||||||
printf " Please start your activity with Basmalah\n\n"
|
|
||||||
break
|
|
||||||
else
|
|
||||||
printf "\n Heey you! why you here!! You are not owner of this machine!\n"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
### ===============================================
|
|
||||||
### END
|
|
||||||
### ===============================================
|
|
||||||
{% endhighlight %}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Welcome to Jekyll!"
|
|
||||||
date: 2013-02-19 21:28:15 +0700
|
|
||||||
categories: [jekyll]
|
|
||||||
---
|
|
||||||
You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.
|
|
||||||
|
|
||||||
To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.
|
|
||||||
|
|
||||||
Jekyll also offers powerful support for code snippets:
|
|
||||||
|
|
||||||
{% highlight ruby %}
|
|
||||||
def print_hi(name)
|
|
||||||
puts "Hi, #{name}"
|
|
||||||
end
|
|
||||||
print_hi('Tom')
|
|
||||||
#=> prints 'Hi, Tom' to STDOUT.
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk].
|
|
||||||
|
|
||||||
[jekyll-docs]: http://jekyllrb.com/docs/home
|
|
||||||
[jekyll-gh]: https://github.com/jekyll/jekyll
|
|
||||||
[jekyll-talk]: https://talk.jekyllrb.com/
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Adding BroadCast Mail to All Users Registered inside Django Admin"
|
|
||||||
date: 2016-04-20 19:51:02 +0700
|
|
||||||
categories: [python, django]
|
|
||||||
image: Broadcast_Mail.png
|
|
||||||
---
|
|
||||||
|
|
||||||
Adding BroadCast Mail to All User Registered in Django Admin. This is my last problem, we need custom default Django Admin to can submit BroadCast mail to All User. Because this is perfectly to make a promotions.
|
|
||||||
|
|
||||||
This problem has been helped by our Danny W. Adair who are answered someone's question about the ["Django Admin Customizing"](http://stackoverflow.com/a/5803941/3445802).
|
|
||||||
|
|
||||||
> In this configuration, we use gmail for email backend. Please following this tutorial first [Email BackEnd with SMTP Gmail](https://agusmakmun.github.io/python/django/2016/04/18/email-backend-with-smtp-gmail.html).
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
**1.** In your `models.py`
|
|
||||||
|
|
||||||
{% highlight python %}
|
|
||||||
class BroadCast_Email(models.Model):
|
|
||||||
subject = models.CharField(max_length=200)
|
|
||||||
created = models.DateTimeField(default=timezone.now)
|
|
||||||
message = RichTextUploadingField()
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return self.subject
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = "BroadCast Email to all Member"
|
|
||||||
verbose_name_plural = "BroadCast Email"
|
|
||||||
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
**2.** In your `admin.py`, importing some module for "admin" and for "email setup".
|
|
||||||
|
|
||||||
{% highlight python %}
|
|
||||||
from django.contrib import admin
|
|
||||||
from django.utils.safestring import mark_safe
|
|
||||||
import threading
|
|
||||||
from django.conf import settings
|
|
||||||
from django.http import HttpResponse
|
|
||||||
from django.core.mail import (send_mail, BadHeaderError, EmailMessage)
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
|
|
||||||
class EmailThread(threading.Thread):
|
|
||||||
def __init__(self, subject, html_content, recipient_list):
|
|
||||||
self.subject = subject
|
|
||||||
self.recipient_list = recipient_list
|
|
||||||
self.html_content = html_content
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
msg = EmailMessage(self.subject, self.html_content, settings.EMAIL_HOST_USER, self.recipient_list)
|
|
||||||
msg.content_subtype = "html"
|
|
||||||
try:
|
|
||||||
msg.send()
|
|
||||||
except BadHeaderError:
|
|
||||||
return HttpResponse('Invalid header found.')
|
|
||||||
|
|
||||||
class BroadCast_Email_Admin(admin.ModelAdmin):
|
|
||||||
model = models.BroadCast_Email
|
|
||||||
|
|
||||||
def submit_email(self, request, obj): #`obj` is queryset, so there we only use first selection, exacly obj[0]
|
|
||||||
list_email_user = [ p.email for p in User.objects.all() ] #: if p.email != settings.EMAIL_HOST_USER #this for exception
|
|
||||||
obj_selected = obj[0]
|
|
||||||
EmailThread(obj_selected.subject, mark_safe(obj_selected.message), list_email_user).start()
|
|
||||||
submit_email.short_description = 'Submit BroadCast (1 Select Only)'
|
|
||||||
submit_email.allow_tags = True
|
|
||||||
|
|
||||||
actions = [ 'submit_email' ]
|
|
||||||
|
|
||||||
list_display = ("subject", "created")
|
|
||||||
search_fields = ['subject',]
|
|
||||||
|
|
||||||
admin.site.register(models.BroadCast_Email, BroadCast_Email_Admin)
|
|
||||||
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
**3.** And then, you can see. we have **Submit BroadCast** selection, just click button **Go** to submit broadcast mail.
|
|
||||||
|
|
||||||

|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Custom redirect urls django"
|
|
||||||
date: 2016-04-20 09:41:20 +0700
|
|
||||||
categories: [python, django]
|
|
||||||
---
|
|
||||||
Example in this problem we need redirect the url `http://localhost:8000/a/b/C/123/4/5/` to `http://localhost:8000/abC12345` without `/` slash.
|
|
||||||
|
|
||||||
#### 1. In your `views.py`
|
|
||||||
|
|
||||||
{% highlight python %}
|
|
||||||
from django.http import HttpResponse
|
|
||||||
from django.views.generic.base import RedirectView
|
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
|
|
||||||
#Ref: http://stackoverflow.com/a/16627830/3445802
|
|
||||||
class UserRedirectView(RedirectView):
|
|
||||||
permanent = False
|
|
||||||
def get_redirect_url(self, pk):
|
|
||||||
pk = ''.join(str(pk).split('/'))
|
|
||||||
return reverse('pool_fix_page', kwargs={'pk': pk})
|
|
||||||
|
|
||||||
def pool_fix(request, pk):
|
|
||||||
return HttpResponse("You're looking at question %s." % pk)
|
|
||||||
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
#### 2. In your `urls.py`
|
|
||||||
|
|
||||||
{% highlight python %}
|
|
||||||
from django.conf.urls import url
|
|
||||||
from . import views
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
# first view the pool to doing redirection
|
|
||||||
url(r'^pool/(?P<pk>[0-9a-zA-Z\/]+)/$', views.UserRedirectView.as_view(), name='pool'),
|
|
||||||
|
|
||||||
# allow decimal and words only.
|
|
||||||
url(r'^pool/(?P<pk>[\d\w_]+)$', views.pool_fix, name='pool_fix_page'),
|
|
||||||
]
|
|
||||||
{% endhighlight %}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Setup Django in apache2 Raspberry Pi"
|
|
||||||
date: 2016-04-20 22:32:34 +0700
|
|
||||||
categories: [django, raspberry]
|
|
||||||
---
|
|
||||||
|
|
||||||
Setup Django in apache2 Raspberry Pi. Example in this configuration for monitoring the server raspberry pi using [https://github.com/k3oni/pydash/](https://github.com/k3oni/pydash/).
|
|
||||||
|
|
||||||
As following this configurations [https://github.com/k3oni/pydash/wiki/Install-pyDash#3-setup-apache](https://github.com/k3oni/pydash/wiki/Install-pyDash#3-setup-apache), how to setup it.
|
|
||||||
|
|
||||||
* **Edit in your:**
|
|
||||||
|
|
||||||
```shell
|
|
||||||
/etc/apache2/sites-available/pydash.conf
|
|
||||||
```
|
|
||||||
|
|
||||||
* **and then, add this configuration:**
|
|
||||||
|
|
||||||
{% highlight ruby %}
|
|
||||||
Listen 192.168.1.27:8001
|
|
||||||
|
|
||||||
<VirtualHost *:8001>
|
|
||||||
ServerName 192.168.1.27:80/pydash
|
|
||||||
ServerAlias 192.168.1.27:8001
|
|
||||||
DocumentRoot /var/www/pydash/
|
|
||||||
WSGIDaemonProcess pydash display-name=%{GROUP} python-path=/var/www/pydash
|
|
||||||
WSGIProcessGroup pydash
|
|
||||||
WSGIScriptAlias / /var/www/pydash/pydash/wsgi.py
|
|
||||||
Alias /static /var/www/pydash/static/
|
|
||||||
Alias /media /var/www/pydash/media/
|
|
||||||
</VirtualHost>
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
* **Now restart or reload your apache**
|
|
||||||
|
|
||||||
```shell
|
|
||||||
service apache2 restart
|
|
||||||
```
|
|
||||||
|
|
||||||
And then, you can access from another client with IP: `192.168.1.27:8001`
|
|
||||||
|
|
||||||
> Thanks to: _Nabil Abdat_
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Javascript Validator for Input Number"
|
|
||||||
date: 2016-04-26 04:19:22 +0700
|
|
||||||
categories: [others]
|
|
||||||
---
|
|
||||||
|
|
||||||
This javascript will validate/allow the number only when event key is pressed.
|
|
||||||
For example result of it:
|
|
||||||
|
|
||||||
<iframe width="100%" height="350" src="//jsfiddle.net/agaust/3qz105nn/embedded/html,result/dark/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
|
||||||
|
|
||||||
tutorial above, when you can not directly add the attribute inside html tag.
|
|
||||||
but if you can add it, you can following this tutorial bellow:
|
|
||||||
|
|
||||||
{% highlight html %}
|
|
||||||
<input id="id_price" type="number" min=0 onkeypress="return isNumber(event)"/>
|
|
||||||
<script type="text/javascript">
|
|
||||||
function isNumber(evt) {
|
|
||||||
evt = (evt) ? evt : window.event;
|
|
||||||
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
|
||||||
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
**Refference:** [http://stackoverflow.com/a/7295864](http://stackoverflow.com/a/7295864)
|
|
||||||
|
|
||||||
hope it usefull.
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "CensorThis - Censor the words [CF]"
|
|
||||||
date: 2016-05-22 04:17:54 +0700
|
|
||||||
categories: [python, codefights]
|
|
||||||
---
|
|
||||||
|
|
||||||
Author Question: **Argaen**
|
|
||||||
|
|
||||||
Code Fights Weekly has gained popularity in the past months and is receiving lots of fan letters. Unfortunately, some of the readers use offensive words and the editor wants to keep the magazine family friendly.
|
|
||||||
|
|
||||||
To manage this, you have been asked to implement a censorship algorithm. You will be given the fan letter `text` and a list of `forbiddenWords`. Your algorithm should replace all occurrences of the forbidden words in the text with sequences of asterisks of the same length.
|
|
||||||
|
|
||||||
Be careful to censor only words, no one want to see `"classic"` spelled as `"cl***ic"`.
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
For text = "The cat does not like the fire" and
|
|
||||||
forbiddenWords = ["cat","fire"], the output should be
|
|
||||||
`CensorThis(text, forbiddenWords) = "The *** does not like the ****".
|
|
||||||
|
|
||||||
* **[input] string text**
|
|
||||||
|
|
||||||
Text to censor, composed of mixed case English words separated by a single whitespace character each.
|
|
||||||
|
|
||||||
* **[input] array.string forbiddenWords**
|
|
||||||
|
|
||||||
The list of words to censor, all in lowercase.
|
|
||||||
|
|
||||||
* **[output] string**
|
|
||||||
|
|
||||||
The censored text. Its length should be the same as the length of text.
|
|
||||||
|
|
||||||
**Solution:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
def CensorThis(text, forbiddenWords):
|
|
||||||
return ' '.join([ t.replace(t, "*" * len(t)) if t.lower() in forbiddenWords else t for t in text.split() ])
|
|
||||||
```
|
|
||||||
|
|
||||||
**Test 1**
|
|
||||||
|
|
||||||
```
|
|
||||||
text: "The cat does not like the fire"
|
|
||||||
forbiddenWords: ["cat", "fire"]
|
|
||||||
Expected Output: "The *** does not like the ****"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Test 2**
|
|
||||||
|
|
||||||
```
|
|
||||||
text: "The cat does not like the therapy"
|
|
||||||
forbiddenWords: ["the", "like"]
|
|
||||||
Expected Output: "*** cat does not **** *** therapy"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Test 3**
|
|
||||||
|
|
||||||
```
|
|
||||||
text: "Python is the BEST programming language and LOLCODE is the Worst"
|
|
||||||
forbiddenWords: ["worst", "best"]
|
|
||||||
Expected Output: "Python is the **** programming language and LOLCODE is the *****"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Test 4**
|
|
||||||
|
|
||||||
```
|
|
||||||
text: "A bald eagle is a worthy adversary"
|
|
||||||
forbiddenWords: ["bald", "a"]
|
|
||||||
Expected Output: "* **** eagle is * worthy adversary"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Test 5**
|
|
||||||
|
|
||||||
```
|
|
||||||
text: "The MAGIC words are fiz buzz and plaf"
|
|
||||||
forbiddenWords: []
|
|
||||||
Expected Output: "The MAGIC words are fiz buzz and plaf"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Test 6**
|
|
||||||
|
|
||||||
```
|
|
||||||
text: "The MAGIC words are fiz buzz and plaf"
|
|
||||||
forbiddenWords: ["fluzz", "z", "ping", "narf", "tedd", "troz", "zort"]
|
|
||||||
Expected Output: "The MAGIC words are fiz buzz and plaf"
|
|
||||||
```
|
|
||||||
|
|
||||||
Thanks to **GOD**.
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "notPaired [CF]"
|
|
||||||
date: 2016-05-22 04:10:03 +0700
|
|
||||||
categories: [python, codefights]
|
|
||||||
---
|
|
||||||
|
|
||||||
Author Question: **Lepluto**
|
|
||||||
|
|
||||||
In Numberland, every integer living there has a soulmate which is the exact same number. To prevent family disasters, the Numberland mayor made sure that there is no more than two of a certain number. However, he clearly forgot to create a pair for one of the numbers, making it very sad and lonely. Given the array representing Numberland's citizens, your task is to find which number you need to add to the array so that everyone has a pair.
|
|
||||||
|
|
||||||
**Example:**
|
|
||||||
|
|
||||||
* `notPaired([1, 2, 1]) = 2`
|
|
||||||
|
|
||||||
2 is the only number in the sequence that appears once.
|
|
||||||
|
|
||||||
* `notPaired([1, 3, 5, 7, 9, 7, 5, 3, 1]) = 9`
|
|
||||||
|
|
||||||
9 is the only number in the sequence that appears once.
|
|
||||||
|
|
||||||
**Input/Output**
|
|
||||||
|
|
||||||
* **[input] array.integer numberland**
|
|
||||||
1 ≤ numberland.length ≤ 100
|
|
||||||
|
|
||||||
* **[output] integer**
|
|
||||||
The final soulmate you need to add to Numberland in order to make everyone happy.
|
|
||||||
|
|
||||||
**Solution:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
def notPaired(numberland):
|
|
||||||
for x in numberland:
|
|
||||||
if numberland.count(x) == 1: return x
|
|
||||||
|
|
||||||
>>> notPaired([1, 3, 5, 7, 9, 7, 5, 3, 1])
|
|
||||||
9
|
|
||||||
>>>
|
|
||||||
```
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Python Crazy Decrypter has been Released"
|
|
||||||
date: 2016-05-21 14:25:20 +0700
|
|
||||||
categories: [python, security]
|
|
||||||
---
|
|
||||||
|
|
||||||
Hello gays, this night i want to share my Python Crazy Decrypter tool. Python Crazy Decrypter is real crazy tool to decrypt md5, sha1, sha224, sha256, sha384, and sha512 with Brute Force method. Like most hashes Decrypter we know used the database to check the hash is valid or not.
|
|
||||||
|
|
||||||
This Python Crazy Decrypter tool use the brute force method with complete charachters or with custom charachters choices, and with Hash Type Checker. But, of course it will spend a long time if the result of hash have a very long length, coz this use the brute force method.
|
|
||||||
|
|
||||||
**Example Usage**
|
|
||||||
|
|
||||||
```
|
|
||||||
$ crazy_decrypter -a 2f2ec1296695a9fb3251bbc94a2e0cef -c ichp 4 4
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example Proccess**
|
|
||||||
|
|
||||||
```
|
|
||||||
*** Please drink your coffee first! ***
|
|
||||||
Python Crazy Decrypter 0.0.4
|
|
||||||
|
|
||||||
CTRL+C to Exit!
|
|
||||||
Charachters to try : ichp
|
|
||||||
Min-length : 3
|
|
||||||
Max-length : 4
|
|
||||||
Type Decrypt found : md5
|
|
||||||
Trying with : iipc - 373fa60ea77f4695bc05fbc1b49d40e3
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example Result**
|
|
||||||
|
|
||||||
```
|
|
||||||
Decrypt found : chip
|
|
||||||
Type Decrypt : md5
|
|
||||||
End time : 06:53:06
|
|
||||||
```
|
|
||||||
|
|
||||||
For more you can checkout on our repository: [https://github.com/agusmakmun/Crazy-Decrypter](https://github.com/agusmakmun/Crazy-Decrypter)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Python Simple Ciphertext"
|
|
||||||
date: 2016-05-21 14:32:04 +0700
|
|
||||||
categories: [python, security]
|
|
||||||
---
|
|
||||||
|
|
||||||
Simply how to make a ciphertext only with 1 line. in this sample, the plaintext is result encoded from hexa. and then, just changing all integer `3` to `6` and also otherwise from `6` to `3`.
|
|
||||||
|
|
||||||
```python
|
|
||||||
>>> #hex_encode = 'summonagus'.encode('hex')
|
|
||||||
>>> hex_encode = '73756d6d6f6e61677573'
|
|
||||||
>>> chip = ''.join([ str(int(a)*2) if a.isdigit() and int(a) == 3 else str(int(a)/2) if a.isdigit() and int(a) == 6 else a for a in hex_encode ])
|
|
||||||
>>>
|
|
||||||
>>> hex_encode
|
|
||||||
'73756d6d6f6e61677573'
|
|
||||||
>>> chip
|
|
||||||
'76753d3d3f3e31377576'
|
|
||||||
>>>
|
|
||||||
>>>
|
|
||||||
```
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Reverse Bit [CF]"
|
|
||||||
date: 2016-05-22 04:04:23 +0700
|
|
||||||
categories: [python, codefights]
|
|
||||||
---
|
|
||||||
|
|
||||||
Author Question: **Giappi**
|
|
||||||
|
|
||||||
I have an integer number, which I want to reverse by following steps:
|
|
||||||
|
|
||||||
1. Convert the number into binary string.
|
|
||||||
2. Reverse binary string.
|
|
||||||
3. Convert the reversed binary string back to integer.
|
|
||||||
|
|
||||||
Can you help me write a function to do it ?
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
For `x = 234`, the output should be `ReverseBit(x) = 87`.
|
|
||||||
|
|
||||||
`23410 = 111010102 => 010101112 = 8710`.
|
|
||||||
|
|
||||||
**Input/Output**
|
|
||||||
|
|
||||||
* **[input] integer x**
|
|
||||||
A non-negative integer.
|
|
||||||
|
|
||||||
* **[output] integer**
|
|
||||||
x reversed as described above.
|
|
||||||
|
|
||||||
**Solution:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
def ReverseBit(x):
|
|
||||||
x = bin(x).replace('0b', '')
|
|
||||||
reverse_text = ''
|
|
||||||
for l in range(len(x)-1, -1, -1):
|
|
||||||
reverse_text = reverse_text + x[l]
|
|
||||||
return int(reverse_text, 2)
|
|
||||||
|
|
||||||
>>> ReverseBit(234)
|
|
||||||
87
|
|
||||||
>>>
|
|
||||||
```
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Find Substrings for line Encoding [CF]"
|
|
||||||
date: 2016-06-11 03:04:23 +0700
|
|
||||||
categories: [python, codefights]
|
|
||||||
---
|
|
||||||
|
|
||||||
Given a string, return its encoding defined as follows:
|
|
||||||
|
|
||||||
First, the string is divided into the least possible number of disjoint **substrings** consisting of identical characters
|
|
||||||
for example, `"aabbbc"` is divided into `["aa", "bbb", "c"]`
|
|
||||||
Next, each substring with length greater than one is replaced with a concatenation of its length and the repeating character
|
|
||||||
for example, substring `"bbb"` is replaced by `"3b"`
|
|
||||||
Finally, all the new strings are concatenated together in the same order and a new string is returned.
|
|
||||||
|
|
||||||
#### SUBSTRING
|
|
||||||
|
|
||||||
A **substring** of a string `S` is another string `S'` that occurs in `S`. For example, `"Fights"` is a substring of `"CodeFights"`, but `"CoFi"` isn't.
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
For `s = "aabbbc"`, the output should be `lineEncoding(s) = "2a3bc"`.
|
|
||||||
|
|
||||||
**Input/Output**
|
|
||||||
|
|
||||||
* [time limit] 4000ms (py)
|
|
||||||
* [input] string s (String consisting of lowercase English letters.)
|
|
||||||
|
|
||||||
_Constraints:_ `4 ≤ s.length ≤ 15.`
|
|
||||||
|
|
||||||
* [output] string (Encoded version of s.)
|
|
||||||
|
|
||||||
**Solution:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
import re
|
|
||||||
def lineEncoding(s):
|
|
||||||
grub = [ m.group(0) for m in re.finditer(r"(\w)\1*", s )]
|
|
||||||
numb = 0
|
|
||||||
out = []
|
|
||||||
for i in grub:
|
|
||||||
numb += 1
|
|
||||||
if len(i) > 1:
|
|
||||||
out.append(grub[numb-1].replace(grub[numb-1], str(len(i))+i[0]))
|
|
||||||
else:
|
|
||||||
out.append(i)
|
|
||||||
return ''.join(out)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Result Tests:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
>>>
|
|
||||||
s = "aabbbc"
|
|
||||||
>>> lineEncoding(s)
|
|
||||||
"2a3bc"
|
|
||||||
>>>
|
|
||||||
>>> s = "abbcabb"
|
|
||||||
>>> lineEncoding(s)
|
|
||||||
"a2bca2b"
|
|
||||||
>>>
|
|
||||||
>>> s = "abcd"
|
|
||||||
>>> lineEncoding(s)
|
|
||||||
"abcd"
|
|
||||||
>>>
|
|
||||||
```
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Find the number of even digits in the given integer [CF]"
|
|
||||||
date: 2016-06-11 03:39:03 +0700
|
|
||||||
categories: [python, codefights]
|
|
||||||
---
|
|
||||||
|
|
||||||
Find the number of even digits in the given integer.
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
* For `n = 1010`, the output should be `numberOfEvenDigits(n) = 2`.
|
|
||||||
* For `n = 123`, the output should be `numberOfEvenDigits(n) = 1`.
|
|
||||||
|
|
||||||
**Input/Output**
|
|
||||||
|
|
||||||
* [time limit] 4000ms (py)
|
|
||||||
* [input] integer n (A positive integer).
|
|
||||||
|
|
||||||
**_Constraints:_**
|
|
||||||
|
|
||||||
* 1 ≤ n ≤ 106.
|
|
||||||
|
|
||||||
* **[output] integer**
|
|
||||||
|
|
||||||
**My Solution:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
def numberOfEvenDigits(n):
|
|
||||||
return len(filter(lambda m: m.isdigit() and int(m) % 2 == 0, str(n)))
|
|
||||||
```
|
|
||||||
|
|
||||||
**Rests Tests:**
|
|
||||||
|
|
||||||
```
|
|
||||||
n: 1010
|
|
||||||
Output: 2
|
|
||||||
|
|
||||||
n: 123
|
|
||||||
Output: 1
|
|
||||||
|
|
||||||
n: 135
|
|
||||||
Output: 0
|
|
||||||
```
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "get Month Name [CF]"
|
|
||||||
date: 2016-06-11 03:43:45 +0700
|
|
||||||
categories: [python, codefights]
|
|
||||||
---
|
|
||||||
|
|
||||||
Map the given integer to a month.
|
|
||||||
|
|
||||||
**Example:**
|
|
||||||
|
|
||||||
* For `mo = 1`, the output should be `getMonthName(mo) = "Jan"`,
|
|
||||||
* For `mo = 0`, the output should be `getMonthName(mo) = "invalid month"`.
|
|
||||||
|
|
||||||
**Input/Output**
|
|
||||||
|
|
||||||
* [time limit] 4000ms (py)
|
|
||||||
* [input] integer mo (A non-negative integer).
|
|
||||||
* **Constraints:** `0 ≤ mo ≤ 15`.
|
|
||||||
* **[output] string**
|
|
||||||
|
|
||||||
A `3`-letter abbreviation of month number `mo` or `"invalid month"` if the month doesn't exist.
|
|
||||||
|
|
||||||
Here are abbreviations of all months:
|
|
||||||
|
|
||||||
**My Solution:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
def getMonthName(mo):
|
|
||||||
months = {
|
|
||||||
1: "Jan", 2: "Feb", 3: "Mar", 4:"Apr",
|
|
||||||
5: "May", 6: "Jun", 7: "Jul", 8:"Aug",
|
|
||||||
9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec"
|
|
||||||
}
|
|
||||||
if mo in months.keys():
|
|
||||||
return months.get(mo)
|
|
||||||
return "invalid month"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Result Tests**:
|
|
||||||
|
|
||||||
```python
|
|
||||||
>>> getMonthName(1)
|
|
||||||
"Jan"
|
|
||||||
>>> getMonthName(0)
|
|
||||||
"invalid month"
|
|
||||||
>>>
|
|
||||||
```
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
---
|
|
||||||
layout: post
|
|
||||||
title: "Top 10 Python libraries of 2016"
|
|
||||||
date: 2016-12-29 18:34:10 +0700
|
|
||||||
categories: [python, django]
|
|
||||||
---
|
|
||||||
|
|
||||||
Last year, we did a recap with what we thought were the [best Python libraries of 2015](https://tryolabs.com/blog/2015/12/15/top-10-python-libraries-of-2015/), which was widely shared within the Python community (see post in[r/Python](https://www.reddit.com/r/Python/comments/3wyiuv/top_10_python_libraries_of_2015/)). A year has gone by, and again it is time to give due credit for the awesome work that has been done by the **open source community** this year.
|
|
||||||
|
|
||||||
Again, we try to avoid most established choices such as Django, Flask, etc. that are kind of standard nowadays. Also, some of these libraries date prior to 2016, but either they had an explosion in popularity this year or we think they are great enough to deserve the spot. Here we go!
|
|
||||||
|
|
||||||
## 1. [Zappa](https://www.zappa.io/)
|
|
||||||
|
|
||||||
Since the release of [AWS Lambda](https://aws.amazon.com/lambda/details/) (and [others](https://cloud.google.com/functions/docs/) that [have](https://azure.microsoft.com/en-us/services/functions/) [followed](https://www.ibm.com/cloud-computing/bluemix/openwhisk)), all the rage has been about [serverless architectures](http://martinfowler.com/articles/serverless.html). These allow microservices to be deployed in the cloud, in a fully managed environment where one doesn’t have to care about managing any server, but is assigned stateless, ephemeral _computing containers_ that are fully managed by a provider. With this paradigm, events (such as a traffic spike) can trigger the execution of more of these _containers_ and therefore give the possibility to handle “infinite” horizontal scaling.
|
|
||||||
|
|
||||||
Zappa is **the serverless framework for Python**, although (at least for the moment) it only has support for AWS Lambda and AWS API Gateway. It makes building so-architectured apps very simple, freeing you from most of the tedious setup you would have to do through the AWS Console or API, and has all sort of commands to ease deployment and managing different environments.
|
|
||||||
|
|
||||||
## 2. [Sanic](https://github.com/channelcat/sanic) + [uvloop](https://magic.io/blog/uvloop-blazing-fast-python-networking/)
|
|
||||||
|
|
||||||
Who said Python couldn’t be fast? Apart from competing for the [best name](http://knowyourmeme.com/memes/sanic-hegehog) of a software library ever, Sanic also competes for the fastest Python web framework ever, and appears to be the winner by a clear margin. It is a Flask-like Python 3.5+ web server that is designed for speed. Another library, _uvloop_, is an ultra fast drop-in replacement for _asyncio_’s event loop that uses [libuv](https://github.com/libuv/libuv) under the hood. Together, these two things make a great combination!
|
|
||||||
|
|
||||||
According to the Sanic author’s [benchmark](https://github.com/channelcat/sanic#benchmarks), _uvloop_ could power this beast to handle more than **33k requests/s** which is just insane (and faster than _node.js_). Your code can benefit from the new _async/await_ syntax so it will look neat too; besides we love the Flask-style API. Make sure to give Sanic a try, and if you are using _asyncio_, you can surely benefit from _uvloop_ with very little change in your code!
|
|
||||||
|
|
||||||
## 3. [asyncpg](https://github.com/MagicStack/asyncpg)
|
|
||||||
|
|
||||||
In line with recent developments for the _asyncio_ framework, the folks from[MagicStack](https://magic.io/) bring us this efficient asynchronous (currently CPython 3.5 only) database interface library designed specifically for PostgreSQL. It has zero dependencies, meaning there is no need to have _libpq_ installed. In contrast with _psycopg2_ (the most popular PostgreSQL adapter for Python) which exchanges data with the database server in text format, _asyncpg_ implements PostgreSQL **binary I/O protocol**, which not only allows support for generic types but also comes with numerous performance benefits.
|
|
||||||
|
|
||||||
The benchmarks are clear: _asyncpg_ is on average, at least **3x faster** than _psycopg2_ (or _aiopg_), and faster than the _node.js_ and _Go_ implementations.
|
|
||||||
|
|
||||||
## 4. [boto3](https://github.com/boto/boto3)
|
|
||||||
|
|
||||||
If you have your infrastructure on AWS or otherwise make use of their services (such as S3), you should be very happy that [boto](https://github.com/boto/boto), the Python interface for AWS API, got a completely rewrite from the ground up. The great thing is that you don’t need to migrate your app all at once: you can use _boto3_ and _boto_ (2) _at the same time_; for example using boto3 only for new parts of your application.
|
|
||||||
|
|
||||||
The new implementation is much **more consistent** between different services, and since it uses a data-driven approach to generate classes at runtime from JSON description files, it will always get fast updates. No more lagging behind new Amazon API features, move to _boto3_!
|
|
||||||
|
|
||||||
## 5. [TensorFlow](https://www.tensorflow.org/)
|
|
||||||
|
|
||||||
Do we even need an introduction here? Since it was released by Google in November 2015, this library has gained a huge momentum and has become the #1 trendiest GitHub Python repository. In case you have been living under a rock for the past year, TensorFlow is a library for **numerical computation** using data flow graphs, which can run over GPU or CPU.
|
|
||||||
|
|
||||||
We have quickly witnessed it become a trend in the Machine Learning community (especially Deep Learning, see our post on [10 main takeaways from MLconf](https://tryolabs.com/blog/2016/11/18/10-main-takeaways-from-mlconf/)), not only growing its uses in research but also being widely used in production applications. If you are doing Deep Learning and want to use it through a higher level interface, you can try using it as a backend for [Keras](https://keras.io/) (which made it to last years post) or the newer [TensorFlow-Slim](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim).
|
|
||||||
|
|
||||||
## 6. [gym](https://gym.openai.com/) + [universe](https://universe.openai.com/)
|
|
||||||
|
|
||||||
If you are into AI, you surely have heard about the [OpenAI](https://openai.com/) non-profit artificial intelligence research company (backed by Elon Musk et al.). The researchers have open sourced some Python code this year! Gym is a toolkit for developing and comparing [reinforcement learning](https://en.wikipedia.org/wiki/Reinforcement_learning) algorithms. It consists of an open-source library with a collection of test problems (environments) that can be used to test reinforcement learning algorithms, and a site and API that allows to compare the performance of trained algorithms (agents). Since it doesn’t care about the implementation of the agent, you can build them with the computation library of your choice: bare numpy, TensorFlow, Theano, etc.
|
|
||||||
|
|
||||||
We also have the recently released _universe_, a software platform for researching into **general intelligence** across games, websites and other applications. This fits perfectly with _gym_, since it allows any real-world application to be turned into a _gym_ environment. Researchers hope that this limitless possibility will **accelerate research** into smarter agents that can solve general purpose tasks.
|
|
||||||
|
|
||||||
## 7. [Bokeh](http://bokeh.pydata.org/)
|
|
||||||
|
|
||||||
You may be familiar with some of the libraries Python has to offer for data visualization; the most popular of which are [matplotlib](http://matplotlib.org/) and [seaborn](http://seaborn.pydata.org/). Bokeh, however, is created for **interactive visualization**, and targets modern web browsers for the presentation. This means Bokeh can create a plot which lets you_explore_ the data from a web browser. The great thing is that it integrates tightly with [Jupyter Notebooks](https://jupyter.org/), so you can use it with your probably go-to tool for your research. There is also an optional server component, `bokeh-server`, with many powerful capabilities like server-side downsampling of large dataset (no more slow network tranfers/browser!), streaming data, transformations, etc.
|
|
||||||
|
|
||||||
Make sure to check the [gallery](http://bokeh.pydata.org/en/latest/docs/gallery.html) for examples of what you can create. They look awesome!
|
|
||||||
|
|
||||||
## 8. [Blaze](https://blaze.readthedocs.io/en/latest/index.html)
|
|
||||||
|
|
||||||
Sometimes, you want to run **analytics** over a dataset too big to fit your computer’s RAM. If you cannot rely on numpy or Pandas, you usually turn to other tools like PostgreSQL, MongoDB, Hadoop, Spark, or many others. Depending on the use case, one or more of these tools can make sense, each with their own strengths and weaknesses. The problem? There is a big overhead here because you need to learn how each of these systems work and how to insert data in the proper form.
|
|
||||||
|
|
||||||
Blaze provides a **uniform interface** that abstracts you away from several database technologies. At the core, the library provides a way to **express computations**. Blaze itself doesn’t actually do any computation: it just knows how to instruct a specific _backend_ who will be in charge of performing it. There is so much more to Blaze (thus the ecosystem), as libraries that have come out of its development. For example, [Dask](http://dask.pydata.org/en/latest/) implements a drop-in replacement for NumPy array that can handle content larger than memory and leverage multiple cores, and also comes with dynamic task scheduling. Interesting stuff.
|
|
||||||
|
|
||||||
## 9. [arrow](https://github.com/crsmithdev/arrow)
|
|
||||||
|
|
||||||
There is a famous saying that there are only two hard problems in Computer Science: cache invalidation and naming things. I think the saying is clearly missing one thing: **managing datetimes**. If you have ever tried to do that in Python, you will know that the standard library has a gazillion modules and types: `datetime`,`date`, `calendar`, `tzinfo`, `timedelta`, `relativedelta`, `pytz`, etc. Worse, it is timezone naive by default.
|
|
||||||
|
|
||||||
Arrow is “datetime for humans”, offering a sensible approach to creating, manipulating, formatting and converting dates, times, and timestamps. It is a**replacement** for the `datetime` type that supports Python 2 or 3, and provides a much nicer interface as well as filling the gaps with new functionality (such as`humanize`). Even if you don’t really _need_ arrow, using it can greatly reduce the boilerplate in your code.
|
|
||||||
|
|
||||||
## 10. [hug](http://www.hug.rest/)
|
|
||||||
|
|
||||||
Expose your internal API externally, drastically simplifying **Python API**development. Hug is a next-generation Python 3 (only) library that will provide you with the cleanest way to create HTTP REST APIs in Python. It is not a web framework per se (although that is a function it performs exceptionally well), but only focuses on exposing idiomatically correct and standard internal Python APIs externally. The idea is simple: you define logic and structure once, and you can expose your API through **multiple means**. Currently, it supports exposing REST API or command line interface.
|
|
||||||
|
|
||||||
You can use type annotations that let _hug_ not only generate **documentation** for your API but also provide with **validation** and clean error messages that will make your life (and your API user’s) a lot easier. Hug is built on [Falcon’s](https://github.com/falconry/falcon) high performance HTTP library, which means you can deploy this to production using any wsgi-compatible server such as [gunicorn](http://gunicorn.org/).
|
|
||||||
|
|
||||||
Follow the discussion of this post on: [Reddit](https://www.reddit.com/r/Python/comments/5jf64k/top_10_python_libraries_of_2016/)
|
|
||||||
|
|
||||||
----------------
|
|
||||||
|
|
||||||
_Original source:_ [_https://tryolabs.com/blog/2016/12/20/top-10-python..._](https://tryolabs.com/blog/2016/12/20/top-10-python-libraries-of-2016/)
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: project_single
|
|
||||||
title: "Cool Project"
|
|
||||||
slug: "cool-project"
|
|
||||||
---
|
|
||||||
Just a demo text for now, which signifies there is lot of scope for improvement.
|
|
||||||
9
about.md
9
about.md
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
title: About
|
|
||||||
permalink: /about/
|
|
||||||
---
|
|
||||||
|
|
||||||
I am freelance developer. Currently doing more in backend, focused in Python and Django.
|
|
||||||
|
|
||||||
email: agus[at]python.web.id
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: bash
|
|
||||||
title: Bash
|
|
||||||
permalink: /category/bash
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: codefights
|
|
||||||
title: Codefights
|
|
||||||
permalink: /category/codefights
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: django
|
|
||||||
title: Django
|
|
||||||
permalink: /category/django
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: jekyll
|
|
||||||
title: Jekyll
|
|
||||||
permalink: /category/jekyll
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: others
|
|
||||||
title: Others
|
|
||||||
permalink: /category/others
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: python
|
|
||||||
title: Python
|
|
||||||
permalink: /category/python
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: raspberry
|
|
||||||
title: Raspberry Pi
|
|
||||||
permalink: /category/raspberry
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: ruby
|
|
||||||
title: Ruby
|
|
||||||
permalink: /category/ruby
|
|
||||||
---
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
layout: posts_by_category
|
|
||||||
categories: security
|
|
||||||
title: Security
|
|
||||||
permalink: /category/security
|
|
||||||
---
|
|
||||||
19
index.html
19
index.html
@@ -3,14 +3,23 @@ layout: default
|
|||||||
---
|
---
|
||||||
|
|
||||||
<div id="home">
|
<div id="home">
|
||||||
<h1>{{ site.title }}</h1>
|
<h1 class="site-header">Crypto Anarchy:</h1>
|
||||||
|
<p class="site-subheader">
|
||||||
|
Encryption, digital money, anonymous networks, digital pseudonyms, zero knowledge, reputations, information markets, black markets, collapse of governments.
|
||||||
|
</p>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<ol class="posts">
|
<h2>Recent Blog Posts</h2>
|
||||||
{% for post in paginator.posts %}
|
<ul class="posts">
|
||||||
<li><a href="{{ post.url }}">{{ post.title }}</a> » <i><span>{{ post.date | date_to_string }}</span></i></li>
|
{% for post in site.posts limit:3 %}
|
||||||
|
<li><a href="{{ post.url }}">{{ post.title }}</a> -- <i><span>{{ post.date | date_to_string }}</span></i></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ul>
|
||||||
|
|
||||||
|
<h2>Getting Started</h2>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
<!-- Pagination links -->
|
<!-- Pagination links -->
|
||||||
{% if paginator.total_pages > 1 %}
|
{% if paginator.total_pages > 1 %}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
layout: project
|
|
||||||
title: Projects
|
|
||||||
permalink: /projects/
|
|
||||||
---
|
|
||||||
|
|
||||||
Few of my projects. Currently doing more in backend, focused in Python and Django.
|
|
||||||
@@ -27,7 +27,7 @@ h1 {
|
|||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
}
|
}
|
||||||
h2, h3 {
|
h2, h3 {
|
||||||
margin-bottom: 5px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
a, a:link, a:active {
|
a, a:link, a:active {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -56,6 +56,9 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Content */
|
/* Content */
|
||||||
|
.site-header, .site-subheader {
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
div.content pre {
|
div.content pre {
|
||||||
background: #333333;
|
background: #333333;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|||||||
Reference in New Issue
Block a user