Skip to content

Instantly share code, notes, and snippets.

View skatesham's full-sized avatar
🏠
Working from home

Sham skatesham

🏠
Working from home
View GitHub Profile
@skatesham
skatesham / Oficina MongoDB e Python FISL
Created August 8, 2017 14:19 — forked from fmasanori/Oficina MongoDB e Python FISL
Oficina MongoDB e Python FISL
Oficina MongoDB e Python - FISL
Resumo university.mongodb.com/courses/M101P/about
Install python 2.7 (provavelmente vc já tem)
https://www.python.org/downloads/
para testar python -V
Install mongoDB 3.4
https://www.mongodb.org/downloads
criar diretório \data\db com as permissões necessárias para testar bin\mongod (servidor)
@skatesham
skatesham / CRUD MongoDB.py
Created August 8, 2017 14:19 — forked from fmasanori/CRUD MongoDB.py
CRUD MongoDB Python2
from datetime import datetime
from pymongo import MongoClient
connection = MongoClient("mongodb://localhost")
db = connection.test
post = {"title": "My Blog Post",
"content": "Here's my blog post.",
"date": datetime.utcnow()}
@skatesham
skatesham / CRUD Excepion.py
Created August 8, 2017 14:19 — forked from fmasanori/CRUD Excepion.py
CRUD MongoDB exception
import pymongo
import sys
def main():
connection = pymongo.MongoClient("mongodb://localhost")
db = connection.m101
people = db.people
person = {'name': 'Barack Obama', 'role':'President',
'address':{'address1':'The White House',
'street': '1600 Pensylvania Avenue',
@skatesham
skatesham / gist:70515b6b9c250f96aa199981f1214097
Created September 12, 2017 04:40 — forked from ilusi/gist:4205101
m101 hw5.1 to 5.4 - Aggregation Framework
// $sum
db.zips.aggregate([
{ $group:
{
"_id": {
"state": "$state"
},
"population": { "$sum": "$pop" }
}
}
@skatesham
skatesham / index.js
Created January 22, 2018 01:16 — forked from codediodeio/index.js
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')();
const sharp = require('sharp')
const _ = require('lodash');
const path = require('path');
const os = require('os');
exports.generateThumbnail = functions.storage.object('uploads/{imageId}').onChange(event => {
const object = event.data; // The Storage object.
@skatesham
skatesham / CategoryRepository.js
Created February 4, 2018 05:59 — forked from lifecoder/CategoryRepository.js
simple DAO example for nodejs
var mongo = require('mongodb'),
EventEmitter = require('events').EventEmitter;
function Connector(settings) {
settings.port = settings.port || mongo.Connection.DEFAULT_PORT;
this.settings = settings;
this.server = new mongo.Server(settings.host, settings.port);
this.db = new mongo.Db(settings.database, this.server, {native_parser: true});
}
@skatesham
skatesham / mongodb-dao.js
Created February 4, 2018 05:59 — forked from JavascriptMick/mongodb-dao.js
Simple Node.js Utility module to enable easy creation of models using node-mongodb-native
/*
Simple Node.js Utility module to enable easy creation of models using node-mongodb-native
Useage:-
var dao = require('./mongodb-dao');
exports.NewClient = function(clientId, plan){
return {
clientId: clientId,
plan: plan,
@skatesham
skatesham / AppWithLocalStorage.vue
Created December 30, 2022 17:27 — forked from lorisleiva/AppWithLocalStorage.vue
Abstraction of the local storage using Vue3's composition API
<script setup>
import useLocalStorage from './useLocalStorage'
const publicKey = useLocalStorage('solana-wallet-public-key')
</script>
<template>
<div>
<input type="text" v-model="publicKey">
<div v-text="publicKey"></div>
</div>