Skip to content

Instantly share code, notes, and snippets.

View adityapurwa's full-sized avatar
🚀
Relearning everything

Aditya Purwa adityapurwa

🚀
Relearning everything
View GitHub Profile
@adityapurwa
adityapurwa / UserTable.vue
Created July 23, 2017 04:35
Component Responsible Model with Vuex Example
load() {
axios.get(this.actionUrl).then((res) => {
this.$store.commit('userManagement/setUsers', res.data);
});
}
@adityapurwa
adityapurwa / Store.js
Created July 23, 2017 04:40
Component Responsible Model with Vuex enforce your Store mutations to be atomic.
const UserManagementModule = {
namespaced: true,
state: {
users: [],
activeUser: {
id: -1,
name: '',
email: '',
password: ''
},
@adityapurwa
adityapurwa / UserForm.vue
Created July 23, 2017 04:50
Component Responsible Model with Vuex utilize event bus to communicate with other related components to update their state.
save() {
if (this.activeUser.id === -1) {
axios.post(this.actionUrl, this.activeUser)
.then((res) => {
alert('user saved');
this.$store.state.userManagement.eventBus.$emit('userManagement/save');
});
} else {
this.update();
}
@adityapurwa
adityapurwa / UserTable.vue
Created July 23, 2017 04:54
Component Responsible Model with Vuex use event bus to know when to update their states.
mounted() {
this.load();
this.$store.state.userManagement.eventBus.$on('userManagement/save', this.load);
}
@adityapurwa
adityapurwa / Dockerfile
Created September 1, 2017 04:49
Dockerfile for Simple Nginx
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
@adityapurwa
adityapurwa / index.html
Created September 1, 2017 04:52
Hello world html used for nginx docker.
<!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>Hello World - Nginx Docker</title>
<style>
h1{
font-weight:lighter;
@adityapurwa
adityapurwa / sample.html
Created October 3, 2017 07:35
A sample implementation of HTMLX guidelines.
<html>
<head>
<link rel="stylesheet" href="style.css"/>
<style>
x{display:block;}
</style>
</head>
<body>
<x class="header">
<x>My Site</x>
$db = new ParticleDb()->connect('localhost', 'root', 'root');
$rows = $db
->select(['title', 'content'])
->from('posts')
->with(['email', 'name'])
->from('users')
->where('users.name','=','Aditya Purwa')
->get();
const transformer = new Transformer("https://myriatek.com/images/logo.png");
const rotate = new RotateTransform(90);
const resize = new ResizeTransform(0.5, 0.5);
const blur = new BlurFilter(8);
const transformedImage = transformer
.apply([rotate, resize])
.filter([blur]);
transformedImage.save(path.resolve(__dirname, 'storage/images'), hash.from(transformedImage.bytes)+transformedImage.extensions);
@adityapurwa
adityapurwa / discrete-math_02_task_01_06.js
Created October 10, 2017 14:12
Ackerman Function in JS
function ackerman(m,n){
if(m == 0){
return n+1;
}
if(m!= 0 && n==0){
return ackerman(m-1,1);
}
if(m!=0 && n!=0){
return ackerman(m-1,ackerman(m,n-1));
}