Skip to content

Instantly share code, notes, and snippets.

Avatar
🃏
Busy or not ?

Adm94

🃏
Busy or not ?
View GitHub Profile
@surajtruckx
surajtruckx / sql.ts
Last active May 8, 2021
Sql Provider
View sql.ts
import { Injectable } from '@angular/core';
import { SQLite } from '@ionic-native/sqlite';
import { Platform } from 'ionic-angular';
import { isEmpty, isNull, keys, sortBy, get, parseInt } from 'lodash';
import { browserDBInstance } from './browser';
declare var window: any;
const SQL_DB_NAME = process.env.IONIC_ENV === 'dev' ? '__broswer.db' : '__native.db';
@Injectable()
@steffenr
steffenr / file_media_entity.php
Last active Sep 4, 2021
[Drupal 8] Create file/ media_entity programmatically
View file_media_entity.php
<?php
$filesystem = \Drupal::service('file_system');
// Create file entity.
$image = File::create();
$image->setFileUri($destination);
$image->setOwnerId(\Drupal::currentUser()->id());
$image->setMimeType('image/' . pathinfo($destination, PATHINFO_EXTENSION));
$image->setFileName($filesystem->basename($destination));
$image->setPermanent();
$image->save();