Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Joaquin Diaz joadr

🏠
Working from home
View GitHub Profile
View restartSound.sh
sudo alsa force-reload
@joadr
joadr / restartBluetooth.sh
Created Jun 27, 2017
restart bluetooth ubuntu
View restartBluetooth.sh
sudo /etc/init.d/bluetooth restart
@joadr
joadr / deploy.sh
Last active Apr 12, 2017
Local Meteor Build for Orion Hostin
View deploy.sh
#!/bin/bash
set -e
echo ""
echo "====> Creating app bundle..."
echo ""
TMPFOLDER=$(mktemp -d)
meteor build --architecture=os.linux.x86_64 $TMPFOLDER --server-only --allow-superuser
echo ""
echo "====> Pushing Bundle"
echo ""
@joadr
joadr / rcomponent.sublime-snippet
Created Oct 19, 2016
ReactComponent Snippet based on filename
View rcomponent.sublime-snippet
<snippet>
<content><![CDATA[
import React from 'react'
const propTypes = {
}
export default class ${1:${TM_FILENAME/^(\w)|(?:-(\w))|(?:.jsx)/(?1\u$1:)(?2\u$2:)/g:ComponentName}} extends React.Component {
constructor (props) {
@joadr
joadr / collection-table.jsx
Created Oct 12, 2016
Create Table From Collection
View collection-table.jsx
import React from 'react'
import { Meteor } from 'meteor/meteor'
import { createContainer } from 'meteor/react-meteor-data'
import {grey400} from 'material-ui/styles/colors'
import ArrowDownward from 'material-ui/svg-icons/navigation/arrow-downward'
import {Table, TableBody, TableHeader, TableHeaderColumn, TableRow} from 'material-ui/Table'
import _ from 'underscore'
class NoItems extends React.Component {
render () {
@joadr
joadr / uploadGridFS.js
Created Oct 6, 2016
Upload files to gridFS server side using vsivi:file-collection meteor package
View uploadGridFS.js
uploadImage = function (itemCode) {
// get the image link
var image = Meteor.call('getImageLink', itemCode)
// Upload to gridFs (vsivi:file-collection)
var imageStream = fc.upsertStream({ filename: itemCode + '.jpg',
contentType: 'image/jpeg',
metadata: {}
})
@joadr
joadr / truncatePrice.js
Last active Oct 6, 2016
Gist to truncate a chilean format.
View truncatePrice.js
// Original price
var price = '$2.968.945'
// remove $ and .
price = price.replace(/\$/g,'').replace(/\./g,'')
// convert to Int
price = parseInt(price)
// Divide by 1000 and truncate to remove extra digits
price = Math.trunc(price/1000)
// Format the final price
price = price*1000-10
@joadr
joadr / urlchanger.js
Created Sep 1, 2016
Mongo gridfs meteor url changer
View urlchanger.js
// When meteor starts
Meteor.startup(function () {
// Recursive function to replace urls
function fixUrl (object) {
_.map(object, function (value, key) {
if (_.isArray(value)) {
_.map(value, function (value2, key2) {
value2 = fixUrl(value2)
})
} else if (_.isObject(value)) {
View FuzzyFilePath config for react and meteor.json
{
"scopes": [
// MINIMAL AUTO TRIGGER - NOT RECOMMENDED
// will always query files for auto completions
// {
// "scope": ".",
// "extensions": ["*"],
// "auto": true
// },
{
@joadr
joadr / Backup and restore Mongo database using gridFs.sh
Last active Oct 6, 2016
Mongo backup and restore database with gridFS
View Backup and restore Mongo database using gridFs.sh
# Conectarse al servidor remoto
$ ssh root@armatubicicleta.cl
# Hago el dump en el sistema remoto
$ mongodump
# Comprimo el archivo en el sistema remoto
$ tar -zcvf armatubicicleta.tgz dump/armatubicicleta/
# Me descargo el archivo a mi sistema local (desde la terminal local)
$ scp root@armatubicicleta.cl:/root/dump/armatubicicleta.tgz /home/joaco/armatubicicleta.tgz
# Descomprimo el archivo
$ tar -zxvf armatubicicleta.tgz
You can’t perform that action at this time.