Skip to content

Instantly share code, notes, and snippets.

View itssomething's full-sized avatar
🎶
BLACK PINK IN YOUR AREA

Manh itssomething

🎶
BLACK PINK IN YOUR AREA
  • Hanoi, Vietnam
View GitHub Profile
@itssomething
itssomething / expa_auth.py
Created February 7, 2018 12:44 — forked from felipeandres254/expa_auth.py
Python 2.7 code snippet to get AIESEC EXPA Token
#!/usr/bin/env python
import re, requests
def GET_TOKEN( email=None, password=None ):
if email and password:
AUTH = {
"user[email]":email,
"user[password]":password
}
r = requests.post("https://auth.aiesec.org/users/sign_in", data=AUTH, verify=False)
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/vi_VN/sdk/xfbml.customerchat.js#xfbml=1&version=v2.12&autoLogAppEvents=1';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
@itssomething
itssomething / bt1
Created October 5, 2018 01:43
các hệ thống phân tán vagina :)
1. Áp dụng kĩ thuật xử lí đa luồng
Khi gửi một request đến server, server sẽ phải xử lí request đó và cpu sẽ được sử dụng. Nếu chỉ sử dụng đơn luồng thì trong thời gian cpu đang xử lí, ta không thể thực hiện một request khác. Ta có thể sử dụng đa luồng ở đây, request được gửi đến sẽ được xử lí bởi một thread riêng biệt, các request tiếp theo cũng sẽ được xử lí bằng các thread khác.
Tuy nhiên khi dùng nhiều thread thì cũng có thể gây tốn bộ nhớ và thời gian. Vì vậy ta có thể xác định xem request nào sử dụng thread nào, khi đó request mới sẽ chờ cho đến khi request trên thread được chạy xong rồi mới thực thi trên chính thread đó.
Ví dụ:
Ta cần cập nhật 10.000 bản khi cùng một lúc, nếu chỉ sử dụng đơn luồng thì việc này có thể tốn nhiều thời gian, tùy thuộc vào dữ liệu cần thay đổi. Ta có thể dùng nhiều thread để xử lí các bản ghi này, từ đó tăng tốc độ thực hiện request và trả về response.
Ta có thể dùng bất đồng bộ để xử lí các request nhanh hơn.
2. Đảm bảo khả năng tương tranh
Để có thể điều khiển tuơng t
$(document).ready(function(){
$('#add-nv').on('click', function(){
var username = $('#username').val();
var name = $('#name').val();
var password = $('#password').val();
var email = $('#email').val();
var department = $('#department').val();
var position = $('#position').val();
var status = $('#status').val();
if (username=='' || name=='' || password==''){
package com.example.admin.calculator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.w3c.dom.Text;
Order.java
public class Order {
private Cart cart;
// auto gen constructor + getter setter
}
BuyApprove.java
public class BuyApprove{
protected BuyApprove nextApprove;
class PlansController < ApplicationController
before_action :init_plan_service
before_action :find_plan, only: %i(edit update)
# after_action :check_plan, only: %i(find_plan)
def index
@plans = plan_service.filter_plan_list
.page(params[:page])
.per Settings.pagination.list
end
package net.guides.springboot2.springboot2webappthymeleaf;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.junit.After;
<%= @questions.each.with_index(1) do |q, index| %>
<div><strong><%= index %>. &nbsp<%= q.name %></strong></div>
<%#= question.answers.each do |answer| %>
<div><%#= answer.content %></div>
<%# end %>
<%= fields_for q do |ff| %>
<div class="answers-list">
<% if q.is_multi? %>
<%= q.answers.each do |a| %>
<div>