Skip to content

Instantly share code, notes, and snippets.

View lcssanches's full-sized avatar
⌨️
Working from home

Lucas Sanches lcssanches

⌨️
Working from home
View GitHub Profile
/* ... */
updateMobile(mobile){
return function (dispatch) {
return axios.post('/update-mobile',{mobile})
.then(response=>{
dispatch(success());
})
.catch(e=>{
dispatch(error())
});
@lcssanches
lcssanches / ExtensionContextClear.cs
Created April 10, 2019 18:13
Entity Framework Core: Clear all tables
public static class ExtensionContextClear {
public static void Clear(this DbContext context) {
var properties = context.GetType().GetProperties();
foreach(var property in properties) {
var setType = property.PropertyType;
bool isDbSet = setType.IsGenericType && (typeof(DbSet < > ).IsAssignableFrom(setType.GetGenericTypeDefinition()));
if (!isDbSet) continue;
var dbSet = (dynamic) property.GetValue(context, null);
@lcssanches
lcssanches / Shortcuts.js
Last active August 24, 2020 06:44
Vanilla Javascript Shortcut mapping
/*
Include this file inside your HEAD tag and add the attribute
`shortcut-key` (or `shortcut-keys`) to any HTML element that accepts .click().
<button shortcut-keys="enter,space">Submit</button>
This code use KeyboardEvent.code to map the shortcuts. See more https://developer.mozilla.org/pt-BR/docs/Web/API/KeyboardEvent/code
*/
(function (d) {
export async function convertAudioToOgg(input: stream.Readable, output: string) {
return new Promise<void>((res, rej) => {
ffmpeg()
.input(input)
.audioChannels(1)
.audioCodec('opus')
.toFormat('ogg')
.addOutputOptions('-avoid_negative_ts make_zero')
.output(output)
.on('progress', function (progress) {