Skip to content

Instantly share code, notes, and snippets.

View blutarche's full-sized avatar
🌞
sunshine and mortality

Aik blutarche

🌞
sunshine and mortality
  • Software Engineer @Cleverse
  • Bangkok, Thailand
  • 15:48 (UTC +07:00)
View GitHub Profile
zshrc () {
exec zsh -l
}
s () {
subl "$1"
}
cyberd () {
@blutarche
blutarche / spamster.py
Created March 8, 2016 16:42
Spam/Ham detect with example dataset.
#!/usr/bin/python
#-*-coding: utf-8 -*-\
import sys
import codecs
import json
from collections import Counter
print ("@relation Spamster")
print ()
@blutarche
blutarche / dll.config.js
Created November 28, 2016 13:38
Webpack config for improving performance of development mode. (https://github.com/erikras/react-redux-universal-hot-example/issues/616)
require('babel-polyfill');
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var assetsPath = path.resolve(__dirname, '../static/dist');
var host = (process.env.HOST || 'localhost');
var port = (+process.env.PORT + 1) || 3001;
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
#include"cstdio"
#include"iostream"
using namespace std;
# define N 1001
int day[N][N] = {0}, minute[N][N] = {0};
void print(int n) {
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
function: Deposit
parameters: Amount, Deadline
code:
- Check if function Caller transfer asset to this contract by at least the Amount.
- if not, reject transaction
- Increase function Caller's balance by Amount.
- Lock this chunk of asset with the deadline.
function: Withdraw
parameters: Amount
@blutarche
blutarche / LoveLetter-base.sol
Last active July 4, 2022 08:15
Solidity x Hardhat 101
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "hardhat/console.sol";
contract LoveLetter {
uint256 public totalLetters;
mapping(uint256 => address) public senders;
mapping(uint256 => address) public receivers;
struct Letter {
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "hardhat/console.sol";
contract LoveLetter {
uint256 public totalLetters;
mapping(uint256 => address) public senders;
mapping(uint256 => address) public receivers;
struct Letter {
contract LoveLetter {
...
function send(address to, string memory message)
external
payable
returns (uint256 id)
{
id = totalLetters;
senders[id] = msg.sender;
contract LoveLetter {
...
function open(uint256 id) external returns (string memory message) {
require(receivers[id] == msg.sender, "Not receiver");
require(!letters[id].opened, "Already opened");
message = letters[id].message;
letters[id].opened = true;
uint256 amount = letters[id].etherAmount;
console.log("[open]", id, amount);
contract LoveLetter {
...
function readMessage(uint256 id)
external
view
returns (string memory message)
{
message = letters[id].message;
}