Skip to content

Instantly share code, notes, and snippets.

View rommyarb's full-sized avatar
👨‍💻
JavaScripting

rommyarb rommyarb

👨‍💻
JavaScripting
View GitHub Profile
@emsifa
emsifa / DB.php
Created September 28, 2016 16:30
Simple CRUD library for php mysqli
<?php
class DB
{
protected static $connection;
public static function initialize($host, $username, $password, $name)
{
if (!static::$connection) {
@megahertz
megahertz / MobxRnnProvider.js
Last active January 11, 2020 09:56
This is a provider which allows to use mobx-react Provider with wix/react-native-navigation.
import { Provider } from 'mobx-react/native';
const SPECIAL_REACT_KEYS = { children: true, key: true, ref: true };
export default class MobxRnnProvider extends Provider {
props: {
store: Object
};
context: {
@pulkitsinghal
pulkitsinghal / sample.js
Last active April 16, 2021 02:53
Add user to role in Parse
var rolesQuery = new Parse.Query(Parse.Role);
rolesQuery.equalTo('name', 'someRole');
return rolesQuery.first({useMasterKey:true})
.then(function(roleObject){
var user = new Parse.User();
user.id = req.params.userId;
roleObject.getUsers().add(user);
return roleObject.save(null, {useMasterKey:true});
});
@thedamon
thedamon / backbutton close bootstrap modal
Created February 28, 2014 17:59
Cause back button to close Bootstrap modal windows
$('div.modal').on('show', function() {
var modal = this;
var hash = modal.id;
window.location.hash = hash;
window.onhashchange = function() {
if (!location.hash){
$(modal).modal('hide');
}
}
});
@putraxor
putraxor / flutter_chat_bubble.dart
Created March 5, 2018 02:19
Flutter Chat Bubble
import 'package:flutter/material.dart';
class Bubble extends StatelessWidget {
Bubble({this.message, this.time, this.delivered, this.isMe});
final String message, time;
final delivered, isMe;
@override
Widget build(BuildContext context) {
@ziad-saab
ziad-saab / get-roles.js
Last active October 4, 2021 15:52
Get a list of a user's roles from Parse, including child roles, up to a certain depth
// Maximum depth is 3, after that we get a "" error from Parse
function getUserRoles(user) {
var queries = [
new Parse.Query('_Role').equalTo('users', user)
];
for (var i = 0; i < 2; i++) {
queries.push(new Parse.Query('_Role').matchesQuery('roles', queries[i]));
}
return user.rolesPromise = Parse.Query.or.apply(Parse.Query, queries).find().then(
@marcolarosa
marcolarosa / gist:f95e7873b747f1f051ee05daca97584d
Last active October 9, 2021 03:52
Converting an excel sheet to json using ExcelJS
import Exceljs from "exceljs";
import { groupBy, compact, isEmpty } from "lodash";
const workbookFile = '/path/to/your/excelSheet/xlsx';
const nameOfSheet = 'name of sheet in workbook';
let workbook = new Exceljs.Workbook();
await workbook.xlsx.readFile(workbookFile);
const sheet = workbook.getWorksheet(nameOfSheet);
<?php
$db_con = mysqli_connect("localhost", "username", "password", "database");
$result = $db_con->query('SELECT * FROM some_table');
if (!$result) die('Couldn\'t fetch records');
$num_fields = mysqli_num_fields($result);
$headers = array();
while ($fieldinfo = mysqli_fetch_field($result)) {
$headers[] = $fieldinfo->name;
}
$fp = fopen('php://output', 'w');
@movibe
movibe / default.nginx
Last active August 4, 2022 06:56
Parse Server Nginx default
# HTTP - redirect all requests to HTTPS
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
}
# HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
# through to Parse Server
server {
@klaszlo8207
klaszlo8207 / scaling_gesture_detector.dart
Last active August 16, 2022 00:44
Flutter ScalingGestureDetector for a 3D view (you can pan and zoom in/out)
import 'package:advert_app/utils/logging.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart';
class ScalingGestureDetector extends StatefulWidget {
final Widget child;
final void Function(Offset initialPoint) onPanStart;
final void Function(Offset initialPoint, Offset delta) onPanUpdate;
final void Function() onPanEnd;