Skip to content

Instantly share code, notes, and snippets.

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

William Tran williamtran29

🏠
Working from home
  • Freelancer
  • Silicon Valley
View GitHub Profile
@williamtran29
williamtran29 / App.js
Created June 29, 2017 12:17 — forked from knowbody/App.js
Check internet connection in React Native app
// quick snippet to check the connection in your RN app
// dispatches an `setIsConnected` action every time the NetInfo changes (on/off network)
componentDidMount() {
const dispatchConnected = isConnected => this.props.dispatch(setIsConnected(isConnected));
NetInfo.isConnected.fetch().then().done(() => {
NetInfo.isConnected.addEventListener('change', dispatchConnected);
});
}
import React from 'react';
import User from './User';
import { connect } from 'react-redux';
import { fetchUsers } from '../actions/index';
import { lifecycle, compose } from 'recompose';
const enhance = compose(
lifecycle({
componentDidMount() {
this.props.fetchUsers();
import { compliment, compose, get } from 'lodash/fp';
import { connect } from 'react-redux';
import { branch, renderComponent } from 'recompose';
const selectIsAuthenticated = state => ({
isAuthenticated: Boolean(state.currentUser),
});
const withAuth = compose(
connect(selectAuthorizationStatus),
@williamtran29
williamtran29 / elixir_timer_interval.exs
Created December 23, 2017 18:04 — forked from kandros/elixir_timer_interval.exs
Set an interval in elixir-lang using erlang timer module
:timer.apply_interval(1000, IO, :puts, ["weeeee"]) # millisends, module, function as atom, list of arguments
@williamtran29
williamtran29 / .eslintrc
Created May 6, 2018 09:44 — forked from radiovisual/.eslintrc
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
# for development
pm2 start npm --name "next" -- run dev
# for production
npm run build
pm2 start npm --name "next" -- start
"scripts": {
"start": "node ./node_modules/.bin/pm2 start app.js -i max --attach"
@williamtran29
williamtran29 / app.js
Created February 13, 2019 16:38 — forked from ekryski/app.js
How to use socket.io in React Native
// You need to set `window.navigator` to something in order to use the socket.io
// client. You have to do it like this in order to use the debugger because the
// debugger in React Native runs in a webworker and only has a getter method for
// `window.navigator`.
window.navigator.userAgent = 'ReactNative';
// Need to require instead of import so we can set the user agent first
// This must be below your `window.navigator` hack above
const io = require('socket.io-client/socket.io');
const socket = io('http://chat.feathersjs.com', {
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@williamtran29
williamtran29 / finetune_llama_v2.py
Created August 9, 2023 13:48 — forked from younesbelkada/finetune_llama_v2.py
Fine tune Llama v2 models on Guanaco Dataset
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@williamtran29
williamtran29 / mlx_finetuning_gemma.ipynb
Created March 16, 2024 05:43 — forked from alexweberk/mlx_finetuning_gemma.ipynb
MLX Fine-tuning Google Gemma
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.