Skip to content

Instantly share code, notes, and snippets.

View thanapongp's full-sized avatar

Thanapong Prathumchat thanapongp

View GitHub Profile
<?php
function filterFile($path)
{
// Read file as array
$content = file($path);
// Remove anything before 'Best rules found:' line
$filtered = array_slice($content, array_search("Best rules found:\n", $content));
@thanapongp
thanapongp / something.java
Created August 16, 2017 06:48
something.java
import java.util.Scanner;
public class HelloWorld
{
public static void main(String[] args)
{
int numbers[] = new int[100];
int i = 0;
int sum = 0;
@thanapongp
thanapongp / what.swift
Last active January 5, 2019 10:17
Code example for What I Learned Ep.1 (Pre-moya)
private func filterUser(for searchText: String) {
if searchText.isEmpty {
return
}
let parameters: Parameters = ["q": searchText.lowercased()]
Alamofire.request("https://api.github.com/search/users", method: .get, parameters: parameters)
.validate()
.responseJSON(completionHandler: { [weak self] response in
import Foundation
import Moya
enum GithubService {
case searchUsers(query: String)
}
extension GithubService: TargetType {
var baseURL: URL {
return URL(string: "https://api.github.com")!
private func filterUser(for searchText: String) {
if searchText.isEmpty {
return
}
let githubServiceProvider = MoyaProvider<GithubService>()
githubServiceProvider.request(.searchUsers(query: searchText), completion: { [weak self] result in
switch result {
case .success(let response):
@thanapongp
thanapongp / index.html
Created April 18, 2019 07:56
Vue.js Clock Angel Problem
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Learn Vue</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
@thanapongp
thanapongp / can-process-barcode.ts
Created May 23, 2019 07:01
Some code example
import { HostListener, ElementRef, ViewChild } from '@angular/core';
export abstract class CanProcessBarCode {
/**
* Key to press in combination with `Alt` key to focus on the input.
* For example: `KeyD` for `Alt + D` combination.
*/
altShortCutCode: string;
/**
@thanapongp
thanapongp / app.1.js
Last active August 18, 2019 08:52
ES6 Todo List EP 2's code snippets
export default class App {
constructor() {
console.log('hello todo!');
}
}
@thanapongp
thanapongp / main.js
Created August 18, 2019 09:11
Initial main.js
class App {
constructor() {
console.log('hello todo!');
}
}
document.addEventListener('DOMContentLoaded', () => {
const app = new App();
});
@thanapongp
thanapongp / app.js
Created August 18, 2019 09:17
Initial app.js
export default class App {
constructor() {
console.log('hello todo!');
}
}