Skip to content

Instantly share code, notes, and snippets.

View DimasInchidi's full-sized avatar
😪
Sleeping

Dimas Ari DimasInchidi

😪
Sleeping
View GitHub Profile
@DimasInchidi
DimasInchidi / main.py
Created July 13, 2018 14:47
simple python web scrapper example
#!/usr/bin/env python
import asyncio
import re
import time
import aiohttp # pip install aiohttp
from bs4 import BeautifulSoup # pip install beautifulsoup4
async def get_response_text(url):
async with aiohttp.ClientSession() as session:
replied = set()
@client.on(events.NewMessage)
async def greet(event: events.NewMessage.Event):
chat_room = await client.get_entity(event.chat_id)
if event.message.is_group and not event.message.from_id in replied:
sender = await event.message.get_sender()
text = 'hi'
replied.add(event.message.from_id)
await client.send_message(chat_room, text)
@DimasInchidi
DimasInchidi / snippets.py
Last active December 26, 2017 13:29
kulgram gist 1
#views.py
from rest_framework import generics, permissions
from portofool_io.serializers import UserProfileSerializer
class Registration(generics.CreateAPIView):
serializer_class = UserProfileSerializer
permission_classes = (permissions.AllowAny,)
# serializers.py
@DimasInchidi
DimasInchidi / expert_chapter_17_1.py
Last active December 9, 2017 18:54
why e.C changed after e.get_md() called?
from pprint import pprint
class E:
R = [1, 2, 3, 4]
C = []
D = []
def get_mc(self):
self.C = self.R
@DimasInchidi
DimasInchidi / django_example.py
Created October 10, 2017 15:22
example of generic view (from django.views import generic and from rest_framework import generics)
##################### models.py
from django.db import models
class BlogModel(models.Model):
name = models.CharField(max_length=32)
##################### serializers.py
from rest_framework import serializers
@DimasInchidi
DimasInchidi / idea64.vmoptions
Last active July 3, 2018 05:37
my IDEA vmoptions
-Xms128m
-Xmx4096m
-XX:MaxMetaspaceSize=512m
-XX:MetaspaceSize=512m
-XX:ReservedCodeCacheSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1
-XX:SurvivorRatio=8
-XX:+UseCodeCacheFlushing
@DimasInchidi
DimasInchidi / Connection.java
Created April 5, 2017 19:22
Simple SQLite in java connection sample
import static java.lang.Class.forName;
import static java.sql.DriverManager.getConnection;
import java.sql.*;
import java.util.*;
public class db {
private static final String JDBC_DRIVER;
private static final String DATABASE_URL;
@DimasInchidi
DimasInchidi / pascal.java
Created March 29, 2017 23:02
Segitiga Paskal Java CLI
class pascal{
public static void main(String[] args) {
java.util.Scanner reader = new java.util.Scanner(System.in);
System.out.print("Enter some number: ");
int ns = reader.nextInt();
for (int n = 0; n < ns; n++) {
for (int j = 0; j < (ns * 3) - (n * 7 / 2) + (ns / 3); j++) {
System.out.print(" ");
}
int nCk = 1;
class Replace {
public static void main (String[] args) throws java.lang.Exception {
Map<String, String> map = new HashMap<String, String>();
//n?kfv-=xa.
map.put("a", "n");
map.put("b", "?");
map.put("c", "k");
map.put("d", "f");
map.put("e", "v");
map.put("f", "-");