working on it ...

Filters

Explore Public Snippets

Sort by

Found 2.3M snippets

    public by lmontealegre modified 23 hours ago  10  0  2  0

    CONSTANT Definitions for Database server and SQL scripts

    Standard for defining connections and SQL definitions
    #=================================================================
    # Database Server Connection String
    # Database = AGENTS  Server = <IP>
    #=================================================================
    CNN_AGENTS = {'Server':'<IP>', 'User':'<Name>', 'Password':'<Pwd>', 'Database':'<DBName>'}
    
    #=================================================================
    # SQL Script Definition to Get Gran Total Agent counts
    # Database = AGENTS  Server = <IP>
    #=================================================================
    SQL_WR0TOTALCNTS = '''
    Select
      Count(SOL.SOL_KEY) As NoRec,
      Count(Distinct SOL.AGT_SOL_NO) As CntSOL,
      Sum(SOL.AGT_SOL_NOFILE) As SumSOL_NF,
      Sum(SOL.AGT_SOL_DWLERR) As SumSOL_DWLERR,
      Sum(SOL.AGT_SOL_OK) As SumSOL_OK,
      Sum(SOL.AGT_SOL_DWLOK) As SumSOL_DWLOK,
      Min(Cast(SOL.AGT_DTE_POSTDATE As datetime)) As Min_POSTDATE,
      Max(Cast(SOL.AGT_DTE_POSTDATE As datetime)) As Max_POSTDATE,
      DateDiff(day, Min(Cast(SOL.AGT_DTE_POSTDATE As datetime)), Max(Cast(SOL.AGT_DTE_POSTDATE As datetime))) As DateRange,
      Count(Distinct Cast(SOL.AGT_DTE_POSTDATE As datetime)) As ProcDates,
      Sum(Case When Len(IsNull(SOL.AGT_SOL_DWLPATH, '')) > 0 Then 1 Else 0
      End) As DwlOK,
      Sum((Convert(bigint,SOL.AGT_SOL_DWLBYTE)) / (1048576)) As MB,
      Count(Distinct SOL.AGT_DTE_EVT) As Cnt_RAN_EVT
    From
      AGENTS.dbo.DIBBS_AGN_SOL SOL
    '''
    
    #=================================================================
    # SQL Script Definition to Get Gran Total Agent counts
    # Database = AGENTS  Server = <IP> To be designed
    #=================================================================
    SQL_SelectedDates = '''
    Select
      Count(SOL.SOL_KEY) As NoRec,
      Count(Distinct SOL.AGT_SOL_NO) As CntSOL,
      Sum(SOL.AGT_SOL_NOFILE) As SumSOL_NF,
      Sum(SOL.AGT_SOL_DWLERR) As SumSOL_DWLERR,
      Sum(SOL.AGT_SOL_OK) As SumSOL_OK,
      Sum(SOL.AGT_SOL_DWLOK) As SumSOL_DWLOK,
      Min(Cast(SOL.AGT_DTE_POSTDATE As datetime)) As Min_POSTDATE,
      Max(Cast(SOL.AGT_DTE_POSTDATE As datetime)) As Max_POSTDATE,
      DateDiff(day, Min(Cast(SOL.AGT_DTE_POSTDATE As datetime)), Max(Cast(SOL.AGT_DTE_POSTDATE As datetime))) As DateRange,
      Count(Distinct Cast(SOL.AGT_DTE_POSTDATE As datetime)) As ProcDates,
      Sum(Case When Len(IsNull(SOL.AGT_SOL_DWLPATH, '')) > 0 Then 1 Else 0
      End) As DwlOK,
      Sum((Convert(bigint,SOL.AGT_SOL_DWLBYTE)) / (1048576)) As MB,
      Count(Distinct SOL.AGT_DTE_EVT) As Cnt_RAN_EVT
    From
      AGENTS.dbo.DIBBS_AGN_SOL SOL
    '''

    public by szmerek modified Sunday at 9:40:13 PM  33  1  3  0

    OnClick without setting an attribute of the link

    //<div id="dog" >Woow woow</div>
    
    
        (function() {
            document.getElementById("dog").onclick = function() { 
                alert('fuf fuf'); 
            };
        })();																		

    public by szmerek modified Sunday at 3:44:27 PM  19  0  2  0

    Remove part of a string before specified character

    //remove string before '&' if want to include character '&' then 'indexOf("&") + 0'
    var str = "black&white";
    str = str.substring(str.indexOf("&") + 1);
    
    //or use regex
    var str = "black&white";
    str = /&(.+)/.exec(str)[1];
    
    // or use .split() and .pop() 
    var str = "black&white";
    str = str.split("&").pop();						

    public by szmerek modified Sunday at 3:39:57 PM  19  0  2  0

    Check whether a string matches a regex

    //RegExp allows to inject variable values into the regex string
    var str = "sample1";
    var re = new RegExp("^([a-z0-9]{5,})$");
    if (re.test(str)) {
        console.log("valid");
    } else {
        console.log("invalid");
    }					

    public by szmerek modified Sunday at 3:38:43 PM  33  0  3  0

    Hide element(s) by class

    Some examples for hiding the class.
    //Ex 
    //<div class="appBanner">appbanner</div> 
    
    document.getElementsByClassName('appBanner')[0].style.visibility = 'hidden';
    
    //change the style rules of all elements matching the class
    
    [].forEach.call(document.querySelectorAll('.appBanner'), function (el) {
      el.style.visibility = 'hidden';
    });
    
    //If for...of is available then use
    
    for (let el of document.querySelectorAll('.appBanner')) el.style.visibility = 'hidden';
    
    //And the other one
    
    Array.filter( document.getElementsByClassName('appBanner'), function(elem){ elem.style.visibility = 'hidden'; });
    
    //and the last one
    
    var appBanners = document.getElementsByClassName('appBanner'), i;
    
    for (i = 0; i < appBanners.length; i += 1) {
        appBanners[i].style.display = 'none';
    }																								

    public by charlwillia6 modified Aug 14, 2017  48  0  1  0

    Uninstall package.json

    Uninstall package.json: npm_uninstall.sh
    # /bin/bash 
    
    npm uninstall `ls -1 node_modules | tr '/\n' ' '`
    
    																								

    public by charlwillia6 modified Aug 14, 2017  51  1  1  0

    Powershell command to rename files to lowercase

    Powershell command to rename files to lowercase: batch_rename_to_lowercase.txt
    Get-ChildItem "C:\Path\To\Pics" -recurse | Where {-Not $_.PSIsContainer} | Rename-Item -NewName {$_.FullName.ToLower()}
    
    																								

    public by Santiago modified Aug 14, 2017  45  0  2  0

    CoreLocatonManager + Rx

    Reactive extension for Core Location manager
    class RxCLLocationManagerDelegateProxy: DelegateProxy, CLLocationManagerDelegate, DelegateProxyType {
      class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) {
        let locationManager: CLLocationManager = object as! CLLocationManager
        locationManager.delegate = delegate as? CLLocationManagerDelegate
      }
      class func currentDelegateFor(_ object: AnyObject) -> AnyObject? {
        let locationManager: CLLocationManager = object as! CLLocationManager
        return locationManager.delegate
      }
    }
    
    extension Reactive where Base: CLLocationManager {
      var delegate: DelegateProxy {
        return RxCLLocationManagerDelegateProxy.proxyForObject(base)
      }
    
      var didUpdateLocations: Observable<[CLLocation]> {
        return delegate.methodInvoked(#selector(CLLocationManagerDelegate.locationManager(_:didUpdateLocations:)))
          .map { parameters in
            return parameters[1] as! [CLLocation]
          }
      }
    }
    

    public by Santiago modified Aug 14, 2017  35  0  2  0

    MKMapView + Rx

    Reactive extension for map view
    class RxMKMapViewDelegateProxy: DelegateProxy, MKMapViewDelegate, DelegateProxyType {
      class func currentDelegateFor(_ object: AnyObject) -> AnyObject? {
        let mapView: MKMapView = (object as? MKMapView)!
        return mapView.delegate
      }
    
      class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) {
        let mapView: MKMapView = (object as? MKMapView)!
        mapView.delegate = delegate as? MKMapViewDelegate
      }
    }
    
    extension Reactive where Base: MKMapView {
      public var delegate: DelegateProxy {
        return RxMKMapViewDelegateProxy.proxyForObject(base)
      }
    
      public func setDelegate(_ delegate: MKMapViewDelegate) -> Disposable {
        return RxMKMapViewDelegateProxy.installForwardDelegate(
          delegate,
          retainDelegate: false,
          onProxyForObject: self.base
        )
      }
    
      var overlays: UIBindingObserver<Base, [MKOverlay]> {
        return UIBindingObserver(UIElement: self.base) { mapView, overlays in
          mapView.removeOverlays(mapView.overlays)
          mapView.addOverlays(overlays)
        }
      }
    
      public var regionDidChangeAnimated: ControlEvent<Bool> {
        let source = delegate
          .methodInvoked(#selector(MKMapViewDelegate.mapView(_:regionDidChangeAnimated:)))
          .map { parameters in
            return (parameters[1] as? Bool) ?? false
          }
        return ControlEvent(events: source)
      }
    }
    

    public by Santiago modified Aug 14, 2017  36  0  3  0

    BindableType protocol implementation

    protocol BindableType
    {
      associatedtype ViewModelType
    
      var viewModel: ViewModelType! { get set }
    
      func bindViewModel()
    }
    
    extension BindableType where Self: UIViewController 
    {
      mutating func bindViewModel(to model: Self.ViewModelType) {
        viewModel = model
        loadViewIfNeeded()
        bindViewModel()
      }
    }
    • Public Snippets
    • Channels Snippets