This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createContext, useContext, useRef } from 'react'; | |
import { Socket } from 'phoenix'; | |
import AuthContext from './AuthContext'; | |
const SocketContext = createContext<Socket>({} as Socket); | |
const SocketConsumer = SocketContext.Consumer; | |
const SocketProvider: React.FC = ({ children }) => { | |
let token = useContext(AuthContext).token!; | |
let socketRef = useRef<{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable ember/no-computed-properties-in-native-classes */ | |
import { render, settled } from '@ember/test-helpers'; | |
import { setupRenderingTest } from 'ember-qunit'; | |
import hbs from 'htmlbars-inline-precompile'; | |
import { module, test } from 'qunit'; | |
import { set, defineProperty, computed } from '@ember/object'; | |
function example(target) { | |
defineProperty( | |
target.prototype, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Taken from the internet | |
// Slighly modified | |
function _n($single, $plural, $number) { | |
if ((int) $number == 1) { | |
return $single; | |
} else { | |
return $plural; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for db in (mysql -u root -e "SHOW DATABASES WHERE `Database` NOT LIKE '%test%'" -s --skip-column-names); | |
mysqldump -u root --single-transaction (string trim $db) > (string trim $db).dump; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from "react"; | |
export default function App() { | |
const [count, setCount] = useState(1); | |
const [autoCount, setAutoCount] = useState(1); | |
useAsyncEffect( | |
function* () { | |
while (true) { | |
yield new Promise((resolve) => setTimeout(resolve, 1000)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Strip EXIF data from JPEGs | |
* | |
* @param {File} file | |
*/ | |
const stripExifFromJPEGs = (file: File): Promise<File | Blob> => { | |
// We want to strip the EXIF data only from JPEGs | |
if (file.type !== 'image/jpeg') { | |
return Promise.resolve(file) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use the following command to install Ruby 2.6.6 | |
# The other 2.6 version might need this as well | |
set -gx optflags "-Wno-error=implicit-function-declaration" | |
set -gx LDFLAGS "-L/opt/homebrew/opt/libffi/lib" | |
set -gx CPPFLAGS "-I/opt/homebrew/opt/libffi/include" | |
set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/libffi/lib/pkgconfig" | |
asdf install ruby 2.6.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem install mysql2 -v '0.5.3' -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd documents | |
$ find . -name "node_modules" -type d -prune -print | xargs du -chs | |
--- Example output --- | |
1.0G ./Github/big-project/node_modules | |
225M ./Github/Trilon.io/node_modules | |
482M ./Github/Some_Demo/node_modules | |
1.7G total |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es2018", | |
"experimentalDecorators": true, | |
"baseUrl": ".", | |
"paths": { | |
"{put-your-app-name-here}/tests/*": ["./tests/*"], | |
"{put-your-app-name-here}/mirage/*": ["./mirage/*"], | |
"{put-your-app-name-here}/*": ["./app/*"] | |
} |
NewerOlder