Skip to content

Instantly share code, notes, and snippets.

View lastday154's full-sized avatar

Steve Hoang lastday154

  • NIT Warangal, India
View GitHub Profile
@lastday154
lastday154 / unitTest.php
Created January 3, 2018 08:01
unitTest
<?php
/**
* Created by PhpStorm.
* User: Zalora
* Date: 4/4/17
* Time: 6:14 PM
*/
class Payment_Model_Adyen_Method_CreditCardTest extends PHPUnit_Framework_TestCase
{
@lastday154
lastday154 / pop-up.html
Created December 12, 2017 04:14
dynamic pop-up
https://codepen.io/ilovecoding197/pen/YYzXzv
@lastday154
lastday154 / refer.cpp
Created December 2, 2017 12:19
Referrer Grab
john = Passenger.create(name: "John")
jim = Passenger.create(name: "Jim", referrer: john)
bob = Passenger.create(name: "Bob", referrer: john)
$5 $3 $1
john -> jim -> alex -> Jane
-> bob -> sally
-> kim
cal_bonus(john) = $19
@lastday154
lastday154 / notifier.js
Created December 2, 2017 12:15
Grab Notifier
class Notifier
{
constructor() {
this.events = [];
}
on(eventName, callback) {
var self = this;
this.events.push(callback);
@lastday154
lastday154 / step.md
Last active December 3, 2017 01:49 — forked from evenchange4/step.md
Deploy a Express.js project on Heroku

Deploy a Express.js project on Heroku

Step by step from command line by Steve Tuan

Quick start

Change app.js to dynamic port

const PORT = process.env.PORT || 3000
app.listen(PORT, () => console.log(`Example app listening on port ${PORT}!`))

@lastday154
lastday154 / missing.cpp
Created November 25, 2017 01:44
Missing interger
// you can use includes, for example:
// #include <algorithm>
#include <unordered_set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
int solution(vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
unordered_set<int> s;
int max = 0;
@lastday154
lastday154 / tour.cpp
Created November 25, 2017 00:43
Tournament Honestbee
#include <iostream>
#include <vector>
using namespace std;
int tour(int num_kid, int x)
{
vector<int> v;
for (int i=0; i<num_kid; i++) {
v.push_back(i);
}
@lastday154
lastday154 / request.py
Created November 25, 2017 00:25
HTTP Request python
import requests
API_URL = 'https://en.wikipedia.org/w/api.php?action=parse&section=0&prop=text&format=json&page='
def get(topic):
r = requests.get(API_URL + topic)
return r.text
def getTopicCount(topic):
text = get(topic)
@lastday154
lastday154 / curl.php
Created November 23, 2017 13:25
curl request php
<?php
$ch = curl_init('https://pal-test.adyen.com/pal/servlet/Payment/v25/refund');
# Setup request to send json via POST.
$payload = '{
"merchantAccount": "ZaloraTW",
"modificationAmount": {
"currency": "TWD",
"value": 8739100.00
},
@lastday154
lastday154 / duplicate.sql
Created November 22, 2017 08:30
Remove duplicate rows mysql
// delete With temp table
CREATE TABLE temp_users AS
SELECT * FROM users GROUP BY user_name;
DROP TABLE users;
RENAME TABLE temp_users TO users;
// delete and keep lower id
DELETE u1 FROM users u1, users u2