- Open https://telegram.me/botfather, create a bot and get a <Bot_token>
- Go to your bot and launch it using
/start
- Add your bot as an admin to the desired chat
- Send a test message to your bot from the channel use
@bot_name
- Get updates received by your bot:
https://api.telegram.org/bot<Bot_token>/getUpdates
- Get the chat_id from the response of step 4
result.$.message.chat.id
, it starts with a-
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
require "open-uri" | |
require "net/http" | |
Error = Class.new(StandardError) | |
DOWNLOAD_ERRORS = [ | |
SocketError, | |
OpenURI::HTTPError, | |
RuntimeError, | |
URI::InvalidURIError, |
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
heroku config:set SECRET_KEY=$(python -c 'import random; import string; print("".join([random.SystemRandom().choice("{}{}{}".format(string.ascii_letters, string.digits, string.punctuation)) for i in range(50)]))') |
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
Thanks to this Gist: https://gist.github.com/avalonalex/8125197 | |
How to use: Make sure Homebrew is installed then run `curl https://gist.githubusercontent.com/zebMcCorkle/fa4508e27f457d7b796ffd474be35d62/raw/59942466b13fe92d09b4b537cc7fcfb309c05c4a/consolas.sh | bash -` |
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
### Keybase proof | |
I hereby claim: | |
* I am Phazz on github. | |
* I am pierrelemperiere (https://keybase.io/pierrelemperiere) on keybase. | |
* I have a public key whose fingerprint is E30C CE1D 447F AAB2 027C 95BB 903E BFB8 2EF6 C132 | |
To claim this, I am signing this object: |
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
#!/bin/env ruby | |
# lazy hack from Robert Klemme | |
module Memory | |
# sizes are guessed, I was too lazy to look | |
# them up and then they are also platform | |
# dependent | |
REF_SIZE = 4 # ? | |
OBJ_OVERHEAD = 4 # ? |
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
class TrieDict | |
attr_reader :dict | |
def initialize | |
@dict = {} | |
end | |
def put(str) | |
d = nil | |
str.chars.each do |c| |
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
require 'benchmark' | |
# | |
# Code example for my blogpost | |
# | |
# Hash lookup in Ruby, why is it so fast? | |
# | |
# | |
# Struct used to store Hash Entries |
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
# call this to get the memory size of the process before and after a treatment | |
def memstats | |
size = `ps -o size= #{$$}`.strip.to_i | |
end |
NewerOlder