Skip to content

Instantly share code, notes, and snippets.

View iamrommel's full-sized avatar

Rommel C. Manalo iamrommel

View GitHub Profile
@iamrommel
iamrommel / Backupscript
Created April 9, 2014 06:00
Create a stored procedure that will backup all selected database in sql server
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Parameter1: databaseName, setting null backup all databases
-- Parameter2: backupType F=full, D=differential, L=log
@iamrommel
iamrommel / SQLServerTricks
Created August 26, 2013 10:54
Delete duplicate records, convert the datetime to date part only, update the master table by using the aggregate function for child table, update a record using joins with other table, and check duplicates
BEGIN TRAN
--This is a sample to delete a duplicate ticket
--Assuming the duplicates are just maximum count as 2
--But if it, more than two run this check several times, because it gets only the MIN value
DELETE FROM dbo.TicketDetails
WHERE Id IN (
SELECT
MIN(t.Id) as Id
FROM dbo.TicketDetails t
mongoimport --host localhost:3001 --db meteor --collection pickups --file pickup.json --drop
{"_id":207285,"ticketNo":"48390","timeStamp":{"$date":"2017-07-30T23:06:55.000Z"},"details":[{"_id":"38714","producerId":"74","gradeTypeId":"3","weight":44075,"timeStamp":{"$date":"2017-07-30T23:06:55.000Z"},"temperature":41},{"_id":"38715","producerId":"66","gradeTypeId":"3","weight":16846,"timeStamp":{"$date":"2017-07-30T23:06:55.000Z"},"temperature":35}],"deliveries":[{"_id":"11656","weight":60921,"timeStamp":{"$date":"2017-07-30T23:06:55.000Z"},"plantId":279,"plantBtuId":259,"plantSiloId":259}]}
{"_id":207286,"ticketNo":"49502","timeStamp":{"$date":"2017-07-31T23:06:55.000Z"},"details":[{"_id":"38716","producerId":"54","gradeTypeId":"3","weight":9474,"timeStamp":{"$date":"2017-07-31T23:06:55.000Z"},"temperature":43},{"_id":"38717","producerId":"260","gradeTypeId":"3","weight":16606,"timeStamp":{"$date":"2017-07-31T23:06:55.000Z"},"temperature":40},{"_id":"38718","producerId":"260","gradeTypeId":"3","weight":8669,"timeStamp":{"$date":"2017-07-31T23:06:55.000Z"},"temperature":39},{"_id":"38719","producerId"
SELECT
(
select
TicketMasters.Id as _id,
dbo.ParseText(TicketMasters.TicketNo) as ticketNo,
dbo.ParseDate(TicketMasters.StartTS) as 'timeStamp.$date',
TicketMasters.Remarks as remarks,
(
SELECT
import React from 'react'
import { MapView } from 'expo'
import {
View,
Text,
H3,
variables,
Content,
Icon,
ListItem,
@iamrommel
iamrommel / Object Flatten
Created February 13, 2018 06:25 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@iamrommel
iamrommel / setting-up-babel-nodemon.md
Created September 18, 2018 04:14 — forked from sam-artuso/setting-up-babel-nodemon.md
Setting up Babel and nodemon

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@iamrommel
iamrommel / Mutation
Created November 13, 2018 09:28
Mutation Component
import React from 'react'
import {Mutation as MutationCore} from 'react-apollo'
import {AsyncStorage} from 'react-native'
// Pull serialized mutations from localstorage
const KEY = '@offlineQueueKey'
const getPending = async () => {
const obj = await AsyncStorage.getItem(KEY)
return JSON.parse(obj) || []
@iamrommel
iamrommel / AddUser
Created November 13, 2018 09:30
Add user using the custom component
import React from 'react'
//import {Mutation} from 'react-apollo'
import {Button, Icon} from 'native-base'
import {Mutation} from './Mutation'
import {ADD_USER, GET_USERS, generateId} from './queries'
const update = (cache, {data: {createUser}}) => {
const {allUsers} = cache.readQuery({query: GET_USERS})
cache.writeQuery({