This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//run this with 'node server.js' and then test in multiple computers using 'telnet 192.168.0.1 9000' | |
// replace '192.168.0.1' with your ip. | |
(function () { | |
'use strict'; | |
let net = require('net'); | |
let chatServer = net.createServer(), | |
clientList = []; // a list of connected clients/ machines | |
chatServer.on('connection', function (client) { | |
//once a client connects we add it to our clientList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mean(obj) | |
{ | |
var props = getProps(obj); | |
var means = []; | |
function findMean(item){ | |
var found = -1; | |
for (var i = means.length - 1; i >= 0; i--) { | |
if(means[i].prop === item){ | |
found = i; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package server | |
import ( | |
"fmt" | |
"net" | |
) | |
type clients []net.Conn | |
// stores all the connected clients | |
var cls clients |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getUsers = ({commit}, params) => { | |
return axios.get('http://api.domain.com/users', { | |
params | |
}).then(resp => { | |
commit('GET_USERS_SUCCESS', resp.data) | |
return resp.data | |
}) | |
} | |
export const getDrivers = ({commit}, params) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axios.defaults.baseURL = 'http://api.domain.com' | |
//then later in your actions | |
axios.get('/users') // to minimize typing the domain in full | |
// getDrivers | |
axios.get('/drivers') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const get = ({commit}, {url = '', params = {}}) => { | |
axios.get(url, { | |
params | |
}).then(resp => { | |
return resp.data | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const get = ({commit}, {url = '', params = {}, type = '', canCommit = true}) => { | |
axios.get(url, { | |
params | |
}).then(resp => { | |
if (canCommit) { | |
commit(type, resp.data) | |
} | |
return resp.data | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get all shops | |
const shops = await this.$store.dispatch('get', { | |
url: '/shops', | |
params: { | |
type: 'all' | |
}, | |
type: 'GET_SHOPS_SUCCESS' | |
}) | |
// use your response if you need to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
name: 'some-component', | |
data () { | |
return { | |
name: 'sadick' | |
} | |
}, | |
methods: { | |
getUsername () { | |
this.$store.dispatch('getUsernameFromAPI') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************************************** | |
* Some fancy comments here * | |
* * | |
***********************************************************/ |
OlderNewer