Skip to content

Instantly share code, notes, and snippets.

View elqsar's full-sized avatar

Boris Musatov elqsar

View GitHub Profile
@elqsar
elqsar / jest.config
Last active January 19, 2021 15:22
Jest config with typescript
module.exports = {
moduleDirectories: ["node_modules", "src"],
// Transforms tell jest how to process our non-javascript files.
// Here we're using babel for .js and .jsx files, and ts-jest for
// .ts and .tsx files. You *can* just use babel-jest for both, if
// you already have babel set up to compile typescript files.
transform: {
// "^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "ts-jest" // or @swc-node/jest
// If you're using babel for both:
@elqsar
elqsar / webpack.config.js
Created September 18, 2015 09:15
Simple webpack config
var path = require('path');
module.exports = {
entry: './app/main.js',
output: {
path: __dirname,
filename: 'bundle.js'
},
devServer: {
@elqsar
elqsar / gist:05080e96c15a0e4cee69
Created March 18, 2015 10:32
Removes all views from parent.
(mainView.subviews as [UIView]).map { $0.removeFromSuperview() }
'use strict';
angular.module('coolModule')
.directive('goFormatSpecialCharacters', function(){
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elem, attrs, ctrl) {
var PATTERN = /\&#{0,1}[A-Za-z0-9]+;/ig;
@elqsar
elqsar / gist:0cdfc0a66beb897aac3d
Created December 9, 2014 16:06
Allow user copy paste text without triggering modal open in Angular directive
function link(scope, element, attr) {
var isDragging = false;
element.addClass('cursor-pointer');
element.on('mousedown', function(){
element.on('mousemove', function(){
isDragging = true;
element.unbind('mousemove');
});
@elqsar
elqsar / ScrollToTop
Created February 28, 2014 19:44
Scroll to top in ScrollView if softkeyboard visible
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final View rootView = getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int height = rootView.getRootView().getHeight() - rootView.getHeight();
if(height > 100) {
loginScrollView.post(new Runnable() {
@elqsar
elqsar / HideSoftkeyboardOnTap
Last active September 12, 2022 11:06
Hide softkeyboard in android application if user tap outside EditText control
protected void setupParent(View view) {
//Set up touch listener for non-text box views to hide keyboard.
if(!(view instanceof EditText)) {
view.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard();
return false;
}
});
}